I am developing a Winform and I need a checkedlistbox. I have the values stored in an object which has a List property:
public static class Fields
{
public static IList<string> FieldList { get; set; }
static Fields()
{ ...//populate FieldList }
}
Now I would like my CheckedListBox to use Fields.FieldList as datasource. After searching online I found I needed to set
//in myForm_Load
mycheckedListBox.DataSource = Fields.FieldList;
But myCheckedListBox does not have a DataSource property.
Am I missing something here?
Per the documentation, it should have this property... http://msdn.microsoft.com/en-us/library/system.windows.forms.checkedlistbox.datasource(VS.90).aspx
However, I also had the same issue on a project a while back, and used this CodeProject article to code the solution in the one project where I needed this feature.
Researching a bit more, I did find this:
Edit: The above link is no longer working, but the exceprt below is from the article that once resided there.
Posted by Microsoft on 5/30/2005 at 10:28 AM
Thanks for the feedback however this is by design. We do not support data binding on the CheckedListBox control. These properties are inherited from it base class and cannot be removed so we hid them form the property grid and IntelliSense.
That explains why the property exists, but doesn't show in Intellisense.
This blog post is worth a read as well: http://waxtadpole.wordpress.com/2009/10/12/assigning-custom-class-to-checkedlistbox-datasource/