Datagridview1.rows [0]. Selected = false;
By default, after data is bound to the datagridview
The first column of the First row is selected.
To achieve this, it is not selected by default (that is, after binding, the first line of the first column is not displayed in the blue)
Previously
Datagridview1.rows [0]. Selected = false;
In the form constructor, it seems that the first column of the First line is still reversed blue.
Later, I tried to put it in the load of the form and finally I couldn't see it as blue.
At the same time, pay attention to the tabindex of datagridview1.
The related code is as follows:
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
Datatable dt = new datatable ();
DT. Columns. Add ("column1 ");
DT. Columns. Add ("column2 ");
DT. Columns. Add ("column3 ");
Datarow DR = DT. newrow ();
Dr ["column1"] = "1 ";
Dr ["column2"] = "2 ";
Dr ["column3"] = "3 ";
DT. Rows. Add (DR );
This. Maid = false;
This. Maid = DT;
// Datagridview1.rows [0]. Selected = false; // put it in form1. The effect cannot be found in form1_load below.
This. button1.focus ();
}
Private void form1_load (Object sender, eventargs E)
{
Datagridview1.rows [0]. Selected = false;
// This. Maid = false;
// Datagridview1.rows [0]. Selected = false;
// This. Maid = NULL;
// Maid ();
}
}