Is it possible to display the selection border in the DataGridView, and not the back color?

My DGV has a BackColors line set to various colors based on business logic. When the user selects a row, the color changes to the selected BackColor row, thereby closing the preset color. I would like to keep the original color when selecting a line and indicate the selection with a (possibly) bold border around the selected line. Is it possible? Is there an easy alternative I'm missing out on?

EDIT To be clear, this is a WinForms application.

+3
source share
3 answers

- . , .

, , ,

Dim backColor as Color = Color.Yellow
row.DefaultCellStyle.BackColor = backColor
row.DefaultCellStyle.SelectionBackColor = Color.FromArgb(backColor.R * 3 / 4, backColor.G * 3 / 4, backColor.B * 3 / 4)

< 1 , , , .

+5

DataGridView , , DataGridView. , DataGridView , .. , , - .

, , , , , . , .

. , datagridview, Microsoft, , .

:

MSDN DataGridView

DataGridView

, , , , , .

, , , .

, googling "datagridview custom behavior".

, Windows Form, -, ?

+3

<SelectedRowStyle CssClass="MyCssClass" />

where you have to create a CSS class to define a table row with your desired border style. Or you can use the inline border style with

<SelectedRowStyle BorderStyle="Solid" BorderWidth="1" BorderColor="Black" />
0
source

Source: https://habr.com/ru/post/1710476/


All Articles