我在vb.net上有代码,只要单击一个单元格就会检查radiobutton3。但是当点击列标题或行标题时它也有效。如何使columheader和rowheader点击这段代码无法使用?
Cursor pointer
答案 0 :(得分:0)
Private Sub MyDataGridView1_MouseDown(sender As Object, e As MouseEventArgs) Handles MyDataGridView1.MouseDown
Dim ht As DataGridView.HitTestInfo
ht = Me.MyDataGridView1.HitTest(e.X, e.Y)
If ht.Type = DataGridViewHitTestType.Cell Then
RadioButton3.Checked = True
cont()
End If
End Sub
此链接有助于: context menu for datagridview cell, rowheader and columnheader
答案 1 :(得分:0)
e.RowIndex = -1表示行标题。 e.ColumnIndex = -1表示列标题。
您可以查看以下内容:
Private Sub shipmentDetailsDataGridView_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs)
RadioButton3.Checked = e.ColumnIndex >= 0 AndAlso e.RowIndex >= 0
End Sub