In my C# program I have a windows form (Winforms) containing a datagridview. The last column of this datagridview is a datagridviewcomboboxcolumn, and each comboboxcell (in each row) has its own datasource.
As there can be a lot of rows, I want to make a binding to populate the datagridview quickly. I already tried to bind the first columns then populate the datasources of the comboboxes afterwards (in the RowsAdded event), but it takes too much time.
My class Data is as follows :
public class Data
{
public string _aaa { get; private set; }
public string _bbb { get; private set; }
public string _ccc { get; private set; }
public List<Room> _rooms_list { get; private set; }
...
}
And the Room class contains the following members :
public ElementId Id { get; }
public virtual string Name { get; set; }
When the datasource of the datagridview is bound to a list of Data objects, I want the corresponding comboboxcell to be filled with the corresponding list of Room objects, with Name as DisplayMember and Id as ValueMember.
I searched on the web but didn't find the answer if it's possible or not.
Thanks a lot for your help.
Edit
More info : I want to let the user select the desired Room among a list of detected/found Rooms, so that's why I chose comboboxes. The results of my calculation already are shown as strings in two of the (bound) string columns.
I also want to make the whole thing sortable, so I use a SortableBindingList to bind the DGV with the list of Data objects : mainDataGridView.DataSource = new SortableBindingList<Data>(_data);