Private Sub DataGridView1_MouseDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles DataGridView1.MouseDown
''右ボタンの確認
If e.Button = Windows.Forms.MouseButtons.Right Then
''マウス下のセルを取得
Dim hti As DataGridView.HitTestInfo = DataGridView1.HitTest(e.X, e.Y)
''セルの場合
If hti.Type = DataGridViewHitTestType.Cell Then
If Not DataGridView1(hti.ColumnIndex, hti.RowIndex).Selected Then
DataGridView1.ClearSelection()
DataGridView1(hti.ColumnIndex, hti.RowIndex).Selected = True
End If
End If
End If
End Sub
|