Try this:
dgv.CurrentCell = dgv[0, 0];
dgv.Rows[0].Selected = false;
It seems that
CurrentCell
for the grid is null until it is displayed or
CurrentCell
is set programatically and in the past I've been unable to use
Selected = true/false
until first setting a
CurrentCell
.
I think you might want to do this in your DataBindingComplete event. So using the code you gave in the comment, it would look something like
private void ItmGroupfrm_Load(object sender, EventArgs e)
{
using DataTable dt = itmGrp.SelectItemGroup());
{
dgv.DataBindingComplete +=
new DataGridViewBindingCompleteEventHandler(dgv_DataBindingComplete);
dgv.DataSource = dt;
}
}
void dgv_DataBindingComplete(object sender,
DataGridViewBindingCompleteEventArgs e)
{
dgv.CurrentCell = dgv[0, 0];
dgv.Rows[0].Selected = false;
}