conditional hightlight row

3 posts, 1 answers
  1. uku
    uku avatar
    57 posts
    Member since:
    Mar 2009

    Posted 15 Nov 2009 Link to this post

    Hello,

    I'm using a data bound gridview. Now I want to show a grid row in yellow if a stock amount listed in the grid is below a certain value and if it's zero I want to show it in red. Is it possible to do this kind of conditional row formatting with RadGridView.

    Any ideas would be great

    Thanks

    Uwe
  2. Answer
    David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 15 Nov 2009 Link to this post

    Hook the Rowloaded event of the grid.
    and override the background property with a new brush

    Something like this

    If TypeOf e.Row Is GridView.GridViewRow Then 
        Dim row As GridView.GridViewRow = e.Row  
        Dim myData as myDataType = ctype(e.DataElement,myDataType)  
     
        select case true  
            case myData.Condition1=bad  
                Row.Background = New SolidColorBrush(Colors.Red)  
            case myData.Condition2=warning  
                Row.Background = New SolidColorBrush(Colors.Yellow)  
            case myData.Condition3=ok  
                Row.Background = New SolidColorBrush(Colors.Green)  
        end select  
     
    End If 
     

    dco

  3. DevCraft banner
  4. uku
    uku avatar
    57 posts
    Member since:
    Mar 2009

    Posted 16 Nov 2009 Link to this post

    Hello David,

    thanks for your solution. Could have thought at this on my own ;-)

    Bye

    Uwe
Back to Top