Link to home
Start Free TrialLog in
Avatar of si2030
si2030

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of si2030
si2030

ASKER

Perfect and timely!!

Thanks jpaulino..

SImon
Glad I could help!
jpaulino