I am trying to bind a CheckedListBox to an Object and when I execute the code, no data is displayed nor I get any errors.
This is what I have in my Type.cs file:
And this is what is in my Type.Designer.cs file:
This is what I have in my Type.cs file:
Code:
private void LoadTypes()
{
CheckedListBox clb = new CheckedListBox();
clb.Name = "clbType";
clb.Sorted = true;
clb.DataSource = _Types; //Object DataSource Collection
clb.DisplayMember = "Type_Name";
clb.ValueMember = "TypeID";
clb.CheckOnClick = true;
clb.BindingContext = new BindingContext();
for (int i = 0; i < clb.Items.Count; i++)
{
if (i % 2 == 0)
{
clb.SetItemCheckState(i, CheckState.Checked);
}
}
this.Controls.Add(clb);
}
Code:
this.clbType.FormattingEnabled = true;
this.clbType.Location = new System.Drawing.Point(149, 187);
this.clbType.Name = "clbType";
this.clbType.Size = new System.Drawing.Size(120, 94);
this.clbType.TabIndex = 42;