my method GetColumns returns a list of column information object. I need to add only the columnname from the object to the checklistbox. How can i do that. From this commented lin of code i’m getting the class name of the object. How can i bind the dynamic checklistbox with the name stored in the object? Please Help….!
List<Columns> DBList = new List<Columns>();
DBList = metadataobj.GetColumns(clbTables.Items[indexofselectedtable].ToString());
chklistcolumns = new CheckedListBox();
for (int j = 0; j < DBList.Count; j++)
{
chklistcolumns.Name = clbTables.Items[indexofselectedtable].ToString();
//chklistcolumns.Items.Add(DBList.ElementAt(j));
;
}
this.Controls.Add(chklistcolumns);
You should call
TypeDescriptor.GetProperties.If all of the objects in the list are the same, you can also call
ListBindingHelper.GetListItemProperties.Unlike reflection, this will also work with types like DataTables.