Datagridview. After selecting a cell, a dotted line will appear around the cell. How can I clear it ??

Source: Internet
Author: User

The grid control is set to read-only, and the mode is set to cell.
After a cell is selected, a dotted line will appear around the cell. I want to remove the dotted line and the background color of the cell remains unchanged.
How can this problem be achieved ???

Reply 1:
The default datagridview does not have this option, but you can achieve this through the following methods:

First, add the cellpaint event of the datagridview,CodeAs follows:
Private void maid (Object sender, maid E)
{
E. Handled = true;
E. paintbackground (E. cellbounds, true );
E. paintcontent (E. cellbounds );
}

//************************************** ****

Datagridview1.clearselection ();
Datagridview1.columnheadersdefaultcellstyle. Alignment = maid. middlecenter;

Datagridview1.defaultcellstyle. selectionbackcolor = color. greenyellow;
Datagridview1.defaultcellstyle. selectionforecolor = color. Black;


This. datagridview1.borderstyle = borderstyle. None;
This. Maid. singlehorizontal;
This. Maid. None;
This. Maid = maid. None;

// This. Maid =
// This. Maid
This. Fig = color. Red;

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.