0

I have a DataGridViewComboBoxColumn that I allow the user to add new items to by typing in the ComboBox and hitting the 'Enter' key. That triggers CellValidating and I do the adding there by the following:

cmbColumn.Items.Add(e.FormattedValue)


All this works well, except that it leaves the DataGridViewComboBoxColumn blank. How can I set the DataGridViewComboBoxColumn to display the e.FormattedValue?

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by tim8w
0

I finally figured it out. Here's what I had to do:

Dim CBox As DataGridViewComboBoxCell = CType(dgvRecipe.Rows(e.RowIndex).Cells(e.ColumnIndex), DataGridViewComboBoxCell)

cmbColumnIngredient.Items.Add(e.FormattedValue)
CBox.Value = e.FormattedValue
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.