I am buidling a user control. Currently it consists of a textbox and a button - as a learning experience. This will be used as a basis for a more useful control.
I want to add a DataSource, display member and ValueMember.
Here is my code for the datasource. It will display in the Properties editor, but is disabled and grayed out. What am I missing?
private object MyDataSource;
[Browsable(true)]
[TypeConverter("System.Windows.Forms.Design.DataSourceConverter")]
[System.ComponentModel.Bindable(true)]
public object DataSource
{
get
{
return MyDataSource;
}
set
{
if (MyDataSource != value)
MyDataSource = value;
}
}
An easier option may be to use an attribute provider instead:
[AttributeProvider(typeof(IListSource))]
You could try using the assembly-qualified name? and specifying the editor?
[TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[Editor("System.Windows.Forms.Design.DataSourceListEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
Actually, you can abbreviate this to be version-independent just by specifying the assembly:
[TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design")]
[Editor("System.Windows.Forms.Design.DataSourceListEditor, System.Design", typeof(UITypeEditor))]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With