C # winform cancel the default cell selected by the datagridview datagrito make it non-blue

Source: Internet
Author: User

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 ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.