Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

Modify a datagridview combobox which is editable to not display the first item automatically..

Hi Experts,

I have a datagridviewcombobox which I have made editable.

The problem is, when I go and click on it I find it automatically populates the combobox with the first item in the drop down. See the following to see what I mean

http://www.screencast.com/users/si2030/folders/Jing/media/9c8d310d-b6c0-4e09-93b4-ecff36cae8b8 

I have used the following code to make it editable. - see the code area.

I want to click on any combobox in this column and be able to type without starting with the first item in it.

I thought you might be able to use selectionStart but I dont know how to apply it - if that is the answer..
Private Sub dgvCreditorInvoiceDetail_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvCreditorInvoiceDetail.EditingControlShowing
 
      If (TypeOf e.Control Is DataGridViewComboBoxEditingControl) Then
 
            Dim cmb As DataGridViewComboBoxEditingControl = CType(e.Control, DataGridViewComboBoxEditingControl)
 
            If (Not cmb Is Nothing) And (dgvCreditorInvoiceDetail.CurrentCellAddress.X = 0) Then
 
                cmb.DropDownStyle = ComboBoxStyle.DropDown
 
            End If
 
        End If
 
    End Sub

Open in new window

0
si2030
Asked:
si2030
  • 2
1 Solution
 
jpaulinoCommented:
Try to change it to this:

        If (TypeOf e.Control Is DataGridViewComboBoxEditingControl) Then
 
            Dim cmb As DataGridViewComboBoxEditingControl = CType(e.Control, DataGridViewComboBoxEditingControl)
 
            If (Not cmb Is Nothing) And (dgvCreditorInvoiceDetail.CurrentCellAddress.X = 1) Then
 
                cmb.DropDownStyle = ComboBoxStyle.DropDown
                cmb.SelectedIndex = -1
            End If
 
        End If

Open in new window

0
 
si2030Author Commented:
Perfect and timely!!

Thanks jpaulino..

SImon
0
 
jpaulinoCommented:
Glad I could help!
jpaulino
 
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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