[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

Editable datagridview combobox not working...

Hi Experts

I am having trouble with an editable combobox for a datagridview. The coe I am using has been obtained from Here:


I using this code:

Private Sub dgvCreditorInvoiceDetail_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvCreditorInvoiceDetail.EditingControlShowing

        If dgvCreditorInvoiceDetail.CurrentCellAddress.X = accountComboBox.DisplayIndex Then

            Dim cmb As ComboBox = CType(e.Control, ComboBox)

            If Not cmb Is Nothing Then

                cmb.DropDownStyle = ComboBoxStyle.DropDown

            End If
End sub

My problem is that the line with "accountComboBox.DisplayIndex has a value of  "-1" and so skips the rest of the lines and this was for the combobox I wanted to be editable.

The "dgvCreditorInvoiceDetail.CurrentCellAddress.X" equals 0...

What am I missing here? How can I get this combobox to be editable?

1 Solution
Is accountComboBox.DisplayIndex  the right combo (the datagridview combo) ?
si2030Author Commented:
Hi there jPaulino,

Good Question! Just found that when I moved the creation of the combobox up to the variables I didnt delete the combobox creation in the sub it was originally created in...

Re-tested it and it now works.



Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now