DataGridView, add unique gradient to each Row

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PeterSchwennesen
    New Member
    • Mar 2008
    • 4

    DataGridView, add unique gradient to each Row

    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:

    Code:
    For Each R As DataGridViewRow In DGV.Rows
        Dim CS As New DataGridViewCellStyle
        Select Case i
             Case 1 : CS.BackColor = Color.Yellow
             Case 2 : CS.BackColor = Color.Blue
        End Select
        R.DefaultCellStyle = CS
    Next
    Is this possible? And How do you do this?
    I am using VB.NET and VS 2008 and 2010

    Peter Schwennesen
  • developer77
    New Member
    • Apr 2010
    • 3

    #2
    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

    Comment

    Working...