Put this code either into your form's constructor or set it in datagridview's Properties using the IDE.
dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgv.MultiSelect = false;
dgv.RowPrePaint +=new DataGridViewRowPrePaintEventHandler(dgv_RowPrePaint);
Then paste the following event into the form code:
private void dgv_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
e.PaintParts &= ~DataGridViewPaintParts.Focus;
}
And it works! :-)
"dgv" is the DataGridView in question and "form" is the Form that contains it.
Note, that this soulution doesn't display the dotted rectangle around the whole row. Instead, it removes the focus dots entirely.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…