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

x
  • 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:

http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/dc2e02c1-0ef7-4721-a075-75e1b37ba1a9/#page:1

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?

Simon
0
si2030
Asked:
si2030
1 Solution
 
jpaulinoCommented:
Is accountComboBox.DisplayIndex  the right combo (the datagridview combo) ?
0
 
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.

Thanks..

Simon
0

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