zytham
zytham

Reputation: 623

Highlight a row with particular color in datagrid

I have a data grid with multiple rows. My requirement is whenever I select a row it should be highlighted. I have disabled the cell selection by giving Background color same as selection color so user feel cell is not selected.

But how to select a row in data grid and highlight it with some color by changing some property ..i am using the following code to make user feel that the cell is not selected.

dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Window;

Upvotes: 0

Views: 882

Answers (1)

Taryn
Taryn

Reputation: 247870

A few questions, do your users need to be able to select individual cells? Since you changed the color of the cell select to make it seem like it is not selected, then how do you decide when to highlight the full row?

It sounds like you want to change the SelectionMode property on your DataGridView. If you change it to FullRowSelect then you will highlight your entire row when any cell in the row is selected.

dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

Upvotes: 1

Related Questions