Click here to Skip to main content
15,916,412 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Datagridview with 5 columns, 3 of which are DatagridviewComboboxes with their style set to Dropdown. When I click on one of the DGVComboboxes it does not highlight blue (showing it is selected), though it does when I mouse over it. I can select the other two textbox cells and they highlight ok. When I select a whole row, the textbox cells highlight but the DGVCombobox cells do not.

Here is how I set the dropdown style for the DGVCombobox, in the DGV's EditingControlShowing event

VB
Private Sub MediaContentsDataGrid_EditingControlShowing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles MediaContentsDataGrid.EditingControlShowing
       'Allow user to enter new values for ALL DataGridViewComboBox controls in the DataGridView
       If (TypeOf e.Control Is DataGridViewComboBoxEditingControl) Then
           Dim cmb As DataGridViewComboBoxEditingControl = CType(e.Control, DataGridViewComboBoxEditingControl)
           If Not cmb Is Nothing Then
               cmb.DropDownStyle = ComboBoxStyle.DropDown

               ' add handler for comboboxes to limit their text length
               AddHandler cmb.KeyPress, AddressOf ContentsDataGridViewComboBoxColumn_KeyPress_MaxLength
           End If
       End If
   End Sub


The DGV as a whole functions fine, and I can use the DGVCombobox cells and even select them, they just don't highlight and appear selected (which is causing user confusion.)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900