I would like to create a derived control from System.Windows.Forms.ComboBox, which is tied to a list of objects that I retrieve from the database. Other developers' ideas may simply discard this control in their form, without worrying about the data source, binding if they don't want to.
I tried extending combobox and then setting the constructor for DataSource, DisplayMember and ValueMember in the constructor.
public class CustomComboBox : ComboBox
{
public CustomComboBox()
{
this.DataSource = MyDAL.GetItems();
this.DisplayMember = "Name";
this.ValueMember = "ItemID";
}
}
Works when I run, but throws a lot of errors in Visual Studio after adding to any form. The error I am getting is:
" " " . :" "
(#, Winforms,.NET 2.0+)?