This is a migrated thread and some comments may be shown as answers.

conditional hightlight row

2 Answers 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
uku
Top achievements
Rank 1
uku asked on 15 Nov 2009, 09:45 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 15 Nov 2009, 03:52 PM
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

0
uku
Top achievements
Rank 1
answered on 16 Nov 2009, 08:35 AM
Hello David,

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

Bye

Uwe
Tags
GridView
Asked by
uku
Top achievements
Rank 1
Answers by
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
uku
Top achievements
Rank 1
Share this question
or