When page is load than datagridview will be bind from database.
I need row enter event for selecting row and based on retriving data from database.
But at load time it should not happen. How can I do this ?
This is my code
private void dgStation_RowEnter(object sender, DataGridViewCellEventArgs e)
{
dgStation.Rows[e.RowIndex].Selected = true;
int id = Convert.ToInt32(dgStation.Rows[e.RowIndex].Cells[1].Value.ToString());
}
You can attach the wire handler after the form is loaded, something like this:
Make sure to remove the current RowEnter handler from the designer file.
Or just use a loading flag: