I am trying to populate a datagridview combobox column with comboboxcells in winforms where each row has a different collection derived from the nested list within the dictionary, the dictionary works fine when i iterate over it and get its objects and their string values, however every different combination i have exhausted to populate the combobox cells on form load has failed. Is it possible? I have found other posts where they use cellclick events etc. I prefer to populate on form initialization.
//this works
public void create datatable()
{
DataGridViewComboBoxColumn Data_CmBx_Col_ObjectType = new DataGridViewComboBoxColumn();
Data_CmBx_Col_FamilyType.Name = _ADD_OBJECT_TYPE;
Data_CmBx_Col_FamilyType.HeaderText = _ADD_OBJECT_TYPE;
dataGridView.Columns.Insert(6, Data_CmBx_Col_ObjectType);
//pop combobox, the dictionary works
int i = 0;
foreach (KeyValuePair<object, List<objectType>> objectAndType in combined_Dictionary)
{
i++;
if (rowIndex <= combined_Dictionary.Count)
{
CreateCustomComboBoxDataSouce(i, objectAndType.Value);
}
}
//Bind dataGridView to a datatable
dataGridView_Family.DataSource = data;
}//end method
//method is called and fails with index out of range error collection
private void CreateCustomComboBoxDataSouce(int row, List<objectAndType> type) //row index ,and two parameters
{
DataGridViewComboBoxCell comboCell = dataGridView_objectAndType[6, row] as DataGridViewComboBoxCell;
comboCell.DataSource = new BindingSource(type, null);
}//end method