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);
Datanot only appears to be missing aRoomvalue variable, but it seems awkward for theDataobject to contain MULTIPLERoomvalues attached to that object. Since these MULTIPLERoomvalues are used for aComboBoxcell in the grid, it would appear only ONE (1) value would be needed for thatDataobject for each row.???? - JohnGDataobject keep what the user selected? If the combo box contains the values above… where in theDataobject are you putting this value to show whatRoomthe user selected? - JohnGDataclass is missing this selectedRoomvalue for thatDataobject. Also as stated above, it seems awkward to have EACHDataobject contain values that it will NEVER use… i.e. the values in itsList<Room> _rooms_listthat were NOT selected by the user. - JohnG