C Datagridview Select Row Right Click

[Solved] C Datagridview Select Row Right Click | Vb - Code Explorer | yomemimo.com
Question : c# datagridview select row right click

Answered by : fragile-fowl-gy4wgcdbp1j1

private void MyDataGridView_MouseDown(object sender, MouseEventArgs e)
{ if(e.Button == MouseButtons.Right) { var hti = MyDataGridView.HitTest(e.X, e.Y); MyDataGridView.ClearSelection(); MyDataGridView.Rows[hti.RowIndex].Selected = true; }
}
private void DeleteRow_Click(object sender, EventArgs e)
{ Int32 rowToDelete = MyDataGridView.Rows.GetFirstRow(DataGridViewElementStates.Selected); MyDataGridView.Rows.RemoveAt(rowToDelete); MyDataGridView.ClearSelection();
}

Source : https://stackoverflow.com/questions/3035144/right-click-to-select-a-row-in-a-datagridview-and-show-a-menu-to-delete-it | Last Update : Fri, 26 Nov 21

Answers related to c datagridview select row right click

Code Explorer Popular Question For Vb