05-27-2009 07:04 AM
I have a datagrid where various columns, one specific column is STATUS. I want to be able to change the color of the fields in the entire row (let's say to red) for rows who have the STATUS field equal to INACTIVE.
How can I do this?
Thank you in advance!
SLX LAN v7.2.1
Solved! Go to Solution.
05-27-2009 07:09 AM
Here you go. Check comments on what to change etc.
Colouring a grid
For the Grid - select the property "OnCustomDrawCell" - this will create a sub based on the name of the grid followed by CustomDrawCell e.g.
Sub dgServicesCustomDrawCell(Sender, ByRef Node, ByRef Column, IsSelected, IsFocused, ByRef Text, ByRef Color, ByRef Alignment, ByRef Font, ByRef FontColor)
sFieldName = UCase ( Column.FieldName ) ' Field you want to look for
Select Case sFieldName
Case "A2_STATUS" ' ALIAS name of the column in QB
lColumnIndex = GetColumnIndexByFieldName ( dgServices,"A2_STATUS" ) ' Used so that grid can be sorted/grouped
vStatus = Node.Values ( lColumnIndex ) ' Gets the actual value
If Not IsNull ( vStatus ) Then ' Ensure you check for Nulls
Select Case vStatus
FontColor = &H00000000 ' in v7.x - you can use enum of clBlack, clGreen etc
FontColor = &H000000FF
FontColor = &H00800000
Font.Bold = True
Function GetColumnIndexByFieldName ( ByRef Grid, ByVal FieldName )
lColumnIndex = -1
For i = 0 To Grid.Columns.Count - 1
If UCase ( Grid.Columns(i).FieldName ) = UCase ( FieldName ) Then
lColumnIndex = i
GetColumnIndexByFieldName = lColumnIndex
07-08-2011 12:13 PM
is it possible to apply the same method to a code that is built in Code. Opportunity products for example. I am using SLX lan version 7.2
07-12-2011 07:26 AM
Yes you can. don't forget that you are dealing with visible Nodes, not the Columns, when colouring. Different animals.
04-02-2012 02:42 PM