Answer the question
In order to leave comments, you need to log in
How to select a cell on RMB in DataGridView?
By clicking on the LMB on the DGV, a cell in the DGV is selected, the CellMouseClick event is called, and so on. When the right mouse button is pressed, all OnMouse... CellMouse... are called, but the cell is not selected. How to fix it?
Answer the question
In order to leave comments, you need to log in
One of the options:
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
dataGridView1.ClearSelection();
dataGridView1[e.ColumnIndex, e.RowIndex].Selected = true;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question