Bind datagridviewcomboboxcolumn with generic collection
Hi,
I want to bind the following class as a collection of objects to a datagridview with one column as combobox.
public class GridClass
{
[DisplayName("ID")]
public string Id { get; set; }
[DisplayName("First Name")]
public string FirstName { get; set; }
[DisplayName("Last Name")]
public string LastName { get; set; }
[DisplayName("Gender")]
public List<string> Gender { get; set; }
public GridClass(string val)
{
Id = val;
FirstName = "FirstName" + val;
LastName = "LastName" + val;
Gender = new List<string>();
Gender.Add("MALE" + val);
Gender.Add("FEMALE" + val);
}
}
I created a datagridview called datagridview1.
Created 5 object of gridclass as follows
BindingList<GridClass> BindList = new BindingList<GridClass>();
for (int i = 1; i <= 5; i++)
{
GridClass g = new GridClass(i.ToString());
BindList.Add(g);
}
I binded to datagridview.
dataGridView1.DataSource = BindList;
But it is displaying only 3 columns ID, First Name and LastName.
I want to display Gender in combobox with each row will have different set of values.
Kindly reply for this post.
Thanks in advance