Page 1 of 1

Datagridview - sağ tıklamada hücreyi seçip menü açma

Posted: Sat Apr 24, 2021 1:46 am
by ahmet
Aşağıdaki kod ile datagrid üzerinde sağ tıklanan hücre seçilir ve menü orada gösterilir

Private Sub DataGridView1_CellMouseDown(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDown
If e.Button <> 2097152 Then Exit Sub 'sağ tıklama
'If e.Button <> MouseButtons.Right Then Exit Sub
Select Case e.RowIndex
Case Is > -1
DataGridView1.CurrentCell = DataGridView1(e.ColumnIndex, e.RowIndex) 'datagrid sağ tıklamada hücreyi seçip menü açma
sagMenu.Show(MousePosition.X, MousePosition.Y)
End Select
End Sub