Hello Everyone,
I am looking for a way to feed the combobox cell of a datagridview during the initialization of the datasource binding operation.
I was hoping to apply the cmb.Items.Add(...) operation there but RowsAdded does not come for each new row, it is a bit random.
If I apply that operation after the binding is completed, it takes a very long time to update the combobox item for in my case 1024 rows.
Does somebody know a way to feed the combobox on demand if I do not use the virtualmode system but the datasource binding way ?
What I have tried:
I tried:
RowsAdded += AdvancedDataGridView_RowsAdded;
private void AdvancedDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
if (_onRowAdded != null)
{
foreach (System.Windows.Forms.DataGridViewRow row in base.Rows)
{
T values = (T)row.DataBoundItem;
values = Copy(values);
_onRowAdded(row, values);
}
}
}
private void OnRowAdded(DataGridViewRow row, Channel values)
{
mpUserControls.DataGridViewColumn col = _grid.Columns["InputMode"];
System.Windows.Forms.DataGridViewCell cell = row.Cells[col.Index];
if (cell is DataGridViewComboBoxCell)
{
DataGridViewComboBoxCell combo = (DataGridViewComboBoxCell)cell;
combo.Value = string.Empty;
combo.Items.Clear();
if (combo.Items.Count <= 0)
{
combo.Items.Add(Channel.netInputMode.INPUTMODE_VOLTAGE.ToString());
if (row.Index % 2 != 0)
combo.Items.Add(Channel.netInputMode.INPUTMODE_ICP.ToString());
}
combo.Value = values.InputMode;
}
}
This works fine for rows index 0 and 1 but not until the 1024 row count.
Do you know if there is a possible way to complete that expectation ?
Thank you so much in advance.
Best regards.
Miqi