DataSource property to control design time

G

Guest

I want to add a DataSource property to my control that, at design time, will allow the designer to drop down a list of valid datasource components just like the DataGrid control. The type on the DataSource property is just 'object', so I know it isn't that. Is there a special designer attribute I have to use on my property

Actually my Control has a Combobox and i just want to enable the combobox's (DataSource, DisplayMember, ValueMember) properties

If I map the properties 1to1 like this

[Category("Data"), DefaultValue(null), Description("The datasource that is used to populate the list with items.")
public object DataSourc

get{return this.comboBox.DataSource;
set{this.comboBox.DataSource = value;


[DefaultValue(""), Description("Gets or sets the column for display."), Category("Data")
public string DisplayMembe

get{return this.comboBox.DisplayMember;
set{this.comboBox.DisplayMember = value;


[DefaultValue(""), Description("Gets or sets the column for value."), Category("Data")
public string ValueMembe

get{return this.comboBox.ValueMember;
set{this.comboBox.ValueMember = value;


It breakes the Designers ability to show a dropdown list of avaiable DataSource's.
 
C

Claes Bergefall

All the DataSource properties (DataGrid, ComboBox etc)
seems to be using a TypeConverterAttribute set to
System.Windows.Forms.Design.DataSourceConverter
Try adding this:

TypeConverter("System.Windows.Forms.Design.DataSourceConverter,
System.Design")

/claes

Morten Lyhr said:
I want to add a DataSource property to my control that, at design time,
will allow the designer to drop down a list of valid datasource components
just like the DataGrid control. The type on the DataSource property is just
'object', so I know it isn't that. Is there a special designer attribute I
have to use on my property?
Actually my Control has a Combobox and i just want to enable the
combobox's (DataSource, DisplayMember, ValueMember) properties.
If I map the properties 1to1 like this:


[Category("Data"), DefaultValue(null), Description("The datasource that is
used to populate the list with items.")]
public object DataSource
{
get{return this.comboBox.DataSource;}
set{this.comboBox.DataSource = value;}
}

[DefaultValue(""), Description("Gets or sets the column for display."), Category("Data")]
public string DisplayMember
{
get{return this.comboBox.DisplayMember;}
set{this.comboBox.DisplayMember = value;}
}

[DefaultValue(""), Description("Gets or sets the column for value."), Category("Data")]
public string ValueMember
{
get{return this.comboBox.ValueMember;}
set{this.comboBox.ValueMember = value;}
}

It breakes the Designers ability to show a dropdown list of avaiable
DataSource's.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top