Click here to Skip to main content
14,739,787 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

What i wanna do is when i select different row in the datagrid the selection to be in different color..

For example, i have 4 rows, now when i select the first row i want it to be green, when i select on 2nd i want it to be red (etc etc, just as an example)

so how could i do this?
Posted
Comments
S@53K^S 23-Mar-12 10:53am
   
Why do you want to have a different color for each row selected.when you can change just the color of the selected rows?
Xonfused 23-Mar-12 17:44pm
   
because the different color will give different meaning to the value that is in the datagrid. (its bit complicated to explain why, but simply i need that)
:)

1 solution

Definitely you can do this.

Just track CellEnter event of datagridview and check if the row is selected or not. If row is selected then change rows color by using following article.

http://msdn.microsoft.com/en-us/library/1yef90x0.aspx

Hope this help!
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900