1private void dataGrid1_MouseDown(object sender, MouseEventArgs e)
2
3{
4
5DataGridView.HitTestInfo Hti;
6
7if (e.Button == MouseButtons.Right)
8
9{
10
11Hti = dataGrid1.HitTest(e.X, e.Y);
12
13if (Hti.Type == DataGridViewHitTestType.Cell)
14
15{
16
17if (!((DataGridViewRow)(dataGrid1.Rows[Hti.RowIndex])).Selected)
18
19{
20
21dataGrid1.ClearSelection();
22
23((DataGridViewRow)dataGrid1.Rows[Hti.RowIndex]).Selected = true;
24
25}
26
27}
28
29}
30
31}