Problems with DataGridViewComboBox

  • Thread starter tim8w via DotNetMonster.com
  • Start date
T

tim8w via DotNetMonster.com

I am using a DataGridViewComboBox in a DataGridView. When a user selects a
radio button, I would like to clear all the items in the DataGridViewComboBox
and repopulate with new values. I do this as follows:

Code:
        Dim iIndex As Integer
Dim dgcb As DataGridViewComboBoxCell

For iIndex = 0 To dgvRecipe.RowCount - 1

dgcb = dgvRecipe.Rows(iIndex).Cells("Measure")
dgcb.Items.Clear()
If radEnglish.Checked Then
dgcb.Items.AddRange(New String() {"t", "T", "Cup", "Quart",
"Gallon", "oz", "lbs"})
Else
dgcb.Items.AddRange(New String() {"mg", "g", "ml", "Litre"})
End If
Next iIndex

It appears to do the job, but later while the control is refreshing i get the
error:

The following exception occured in the DataGridView:

System.ArguementException: DataGridViewComboBoxCell value is not valid.

To replace this default dialog please handle the DataError event.[/QUOTE]

Any ideas?
 
T

tim8w via DotNetMonster.com

Just needed to either clear or set to a new value any items that were set to
the old ComboBox items...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top