We can do this using DataGridView.CellClick event. The following code is enough to open the ComboBox and fire its DropDown event.
Private Sub DataGridView1_CellClick(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
Handles DataGridView1.CellClick
'enters into edit mode
DataGridView1.BeginEdit(True)
'checking if the editing control is a combobox
If TypeOf (DataGridView1.EditingControl) Is ComboBox Then
'casting the editing control and fire DropDown event
CType(DataGridView1.EditingControl, ComboBox).DroppedDown = True
End If
End Sub
DataGridView.EditingControl represents the control hosted by the current cell.
Very nice. It works.
ReplyDeleteAhsan
Islamabad, Pakistan