By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,716 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,716 IT Pros & Developers. It's quick & easy.

DataGridView, add unique gradient to each Row

P: 4
I like to add a gradient brush to each row of my datagridview. I like to change the gradient colors for each row independently depending of some cell values in the row.

I know how to add a solid background color to each, cell, row, column etc. but I do not know how to add a gradient brush to each row individualy.

I need to fill the datagridview with values, the datagridview is disconnected from any database or other data source. After filling the datagridview, I want to step trough each row, find my key values, decide the gradient colors and then add the gradient to the row.

I like to do something similar to what I now do with a background color:

Expand|Select|Wrap|Line Numbers
  1. For Each R As DataGridViewRow In DGV.Rows
  2.     Dim CS As New DataGridViewCellStyle
  3.     Select Case i
  4.          Case 1 : CS.BackColor = Color.Yellow
  5.          Case 2 : CS.BackColor = Color.Blue
  6.     End Select
  7.     R.DefaultCellStyle = CS
  8. Next
Is this possible? And How do you do this?
I am using VB.NET and VS 2008 and 2010

Peter Schwennesen
Apr 22 '10 #1
Share this Question
Share on Google+
1 Reply

P: 3
I think you need to create a derived control from the datagridview, and paint this yourself. Perhaps someone else has specifics, but it may give you an idea. Also - search for "custom draw" and "owner drawn" in the contxt of the DataGridView
Apr 23 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.