I have a datagridview which is populated from a dataset.
Once it is populated, if the user clicks on a row, the last column should change from textbox to combobox.
I am using vb.net 2010.
On the Datagridview1 CellClick event:
With DataGridView1
If .Rows.Count = 0 Then Exit Sub
i = Datagridview1.currentrow.index
Dim gridComboBox As New DataGridViewComboBoxCell
gridComboBox.Items.Add("A") 'Populate the Combobox
gridComboBox.Items.Add("B") 'Populate the Combobox
gridComboBox.Items.Add("C") 'Populate the Combobox
.Item(8, i) = gridComboBox
End With
But this results in an error:
The following exception occurred in DataGridView:
System.Argument.Exception: DataGridViewComboBoxCell value is not valid.
To replace this default dialog please handle the DataError event.
If the situation is not feasible, I want the last column to be of type combobox upon populate of data from the dataset.
DataGridView1.DataSource = myDataSet
Thanks in advance.