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?

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.