Search code examples
c#winformsdatagridview

How to set value to DataGridViewComboBox Column?


I want to know how to set the value of a DataGridViewComboBox cell. I already bind the DataGridViewComboBox with DataSource. But I want to set new value to this this datasource.

This is what i have so far:

gvList.Rows[0].Cells[0].value = "Select";

But it throws an error saying: Format Exception: DataGridViewComboBox Cell value is not valid .

How could I achieve this without error?


Solution

  • The error is due to the fact that you have bound a DataSource to the ComboBox column and while you assign Select its trying to locate the same in the DataSource its bound too. Your best bet will be to add the same to the original DataSource which you bind to the ComboBox column