16,554
社区成员
发帖
与我相关
我的任务
分享
Private Sub DataGridView1_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvDocumentList.CellMouseClick
If e.Button = MouseButtons.Left Then
Return
End If
If e.ColumnIndex = 1 AndAlso e.RowIndex >= 0 Then
' 第一行的菜单设置
If e.RowIndex = 1 Then
ContextMenuStrip1.Items.Item("xxxxx").Visible = False
End If
End If
End Sub
Private Sub DGV_List_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DGV_List.CellMouseClick
If e.Button = MouseButtons.Right Then
If e.RowIndex >= 0 Then
DGV_List.Rows(e.RowIndex).Selected = True
DGV_List.CurrentCell = DGV_List.Rows(e.RowIndex).Cells(1)
ContextMenu_DGV.Show(DGV_List, e.Location)
ContextMenu_DGV.Show(Cursor.Position)
'下面的代码可以根据e参数来获取DGV_List的行或列的信息来设置IF条件
'If DGV_List.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = 0 Then
ContextMenu_DGV.Items.Item(0).Visible = False
ContextMenu_DGV.Items.Item(1).Enabled = False
'End If
End If
End If
End Sub