DataGridview属性EditMode设为EditOnEnter
添加如下事件代码
Private Sub dgvZhiJianXiangMu_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvZhiJianXiangMu.CellClick
If e.ColumnIndex >= 0 AndAlso e.RowIndex >= 0 AndAlso dgvZhiJianXiangMu(e.ColumnIndex, e.RowIndex) IsNot Nothing AndAlso Not dgvZhiJianXiangMu(e.ColumnIndex, e.RowIndex).ReadOnly Then
Dim comboBoxColumn As DataGridViewComboBoxColumn = TryCast(dgvZhiJianXiangMu.Columns(e.ColumnIndex), DataGridViewComboBoxColumn)
If comboBoxColumn IsNot Nothing Then
Me.dgvZhiJianXiangMu.CurrentCell = dgvZhiJianXiangMu(e.ColumnIndex, e.RowIndex)
dgvZhiJianXiangMu.BeginEdit(True)
Dim comboBoxEditingControl As DataGridViewComboBoxEditingControl = TryCast(dgvZhiJianXiangMu.EditingControl, DataGridViewComboBoxEditingControl)
If comboBoxEditingControl IsNot Nothing Then
comboBoxEditingControl.DroppedDown = True
End If
End If
End If
End Sub
效果如下
标签:comboBoxEditingControl,控件,VB,End,RowIndex,DataGridview,ColumnIndex,DataGridViewC From: https://www.cnblogs.com/songchunlin/p/18060883