DataGridView daily problems...

i have a DataGridview with some ComboBox cells in there.

each row should have a different list of items to select the value from.

you can set the bindingsource on Enter and reset the bindingsource to the list with all items on EndEdit...


in dataGridView CellEnter
if (e.ColumnIndex == CELLINDEXWhereComboBoxIs) { //Set DataSource of cell if comboBoxCell DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dataGridView[e.ColumnIndex, e.RowIndex]; cell.DataSource = bindingSourceFiltered; }

in dataGridView CellEndEdit

if (e.ColumnIndex == CELLINDEXWhereComboBoxIs) { //set DataSource to BindingSource with all items DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dataGridView[e.ColumnIndex, e.RowIndex]; cell.DataSource = bindingSourceAll; }


ps:
you can add filters to the bindingsource!
but only if the underlying list supports filtering!!

Latest Posts

Popular Posts