How do you select a datagridview row on a right-click?
from @Alan Christensen
code convert to VB.NET
Private Sub dgvCustomers_CellMouseDown(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvCustomers.CellMouseDown
If e.Button = MouseButtons.Right Then
dgvCustomers.CurrentCell = dgvCustomers(e.ColumnIndex, e.RowIndex)
End If
End Sub
I am tested on VS 2017 it working for me!!!
If e.Button = MouseButtons.Right Then
DataGridView1.CurrentCell = DataGridView1(e.ColumnIndex, e.RowIndex)
End If
code works in VS2019 too
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With