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;