datagridview选择单元格
pcdmis吧
全部回复
仅看楼主
level 6
PCDLRN 楼主
Private Sub DataGridView1_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDown
If e.Button = Windows.Forms.MouseButtons.Right Then
If e.RowIndex >= 0 And e.ColumnIndex >= 0 Then '选中行头或列头均不触发
'若行已是选中状态就不再进行设置
If DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Selected = False Then
DataGridView1.ClearSelection()
DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Selected = True
End If
End If
End If End Sub
2013年05月27日 00点05分 1
1