6/7/2025 3:22:46 PM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
|
|
|
|
Changing DataGrid Cell Colors
Posted: 23 Aug 07 8:42 PM
|
Question: Is it possible to dynamically change the background color of a single cell based on the value of the displayed field. Say I've got a column based on a Boolean field, and the column type is the "Check" box type. That works well, but I'd also now like to change the color for cells which have been checked. |
|
|
|
Re: Changing DataGrid Cell Colors
Posted: 24 Aug 07 4:04 AM
|
Yes.
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)
Dim sFieldName Dim vStatus Dim lColumnIndex
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 End Select
If Not IsNull ( vStatus ) Then ' Ensure you check for Nulls
Select Case vStatus Case "Open" FontColor = &H00000000 ' in v7.x - you can use enum of clBlack, clGreen etc Case "Lost" FontColor = &H000000FF Case "Won" FontColor = &H00800000 Font.Bold = True End Select End If
End Sub
'========================================================================================== Function GetColumnIndexByFieldName ( ByRef Grid, ByVal FieldName ) Dim i Dim lColumnIndex
lColumnIndex = -1 For i = 0 To Grid.Columns.Count - 1 If UCase ( Grid.Columns(i).FieldName ) = UCase ( FieldName ) Then lColumnIndex = i Exit For End If Next GetColumnIndexByFieldName = lColumnIndex End Function |
|
|
| |
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|