Dynamic ComboBox in DataGridView

I have a DataGridView with 4 columns, one of which is a drop down column (ComboBox). The values ​​in this column should be separate, so when the drop-down values ​​are selected in a row, I would like it not to be available in any of the drop-down lists in other rows. If the setpoint is not selected, it should appear in the drop-down lists again. I found several articles with similar examples ( 1 , 2 , 3 ); however, they all seem to be associated with an event subscription and manually populate the ComboBox.

  • Is there a way to accomplish this only with data binding (possibly to IEnumerable, which is basically a all.Except(selected)Linq query )?
  • If data binding is not enough, is there a better way to do this than the examples I found?

I'm a little new to WinForms development, so I can’t talk about good advice from "yes ... it will work, sort of."

+1
source share
1 answer

I'm afraid that your search is still true - there is no better way to provide different lists of lists in the same column the DataGridView, than the subscription events (usually CellBeginEdit, and CellEndEdit), and then setting the DataSource for an individual DataGridViewComboBoxCell).

FAQ DataGridView, Mark Rideout, DataGridView Microsoft. , , .

+1

All Articles