back to top

Formatting a datagrid’s cells to have custom colors in the SalesLogix LAN client

A client recently posed a question to me regarding if you can customize the SalesLogix grid in the LAN client to have coloring applied based upon conditions.  The answer is yes you can.  lets take a look at how.

The SalesLogix data grid control has an event called OnCustomDrawCell.  This event has several arguments that are passed in including:

  • Sender- the grid control
  • Node- The row in the grid
  • Column- The column being rendered
  • IsSelected- A boolean expressing if the cell is selected
  • IsFocused- A boolean expressing if the cell is currently in focus
  • Text- Writable property relating to the text displayed in the grid
  • Color- Writable property relating to the background color of the cell displayed in the grid
  • Alignment- Writable property relating to the text alignment in the grid 
  • Font- Writable property relating to the text’s font displayed in the grid
  • FontColor- Writable property relating to the text’s color displayed in the grid

Lets take a look at how we might examine the contents of a given row, and then based on that information do something to another cell:

Sub grdContactsCustomDrawCell(Sender, ByRef Node, ByRef Column, IsSelected, IsFocused, ByRef Text, ByRef Color, ByRef Alignment, ByRef Font, ByRef FontColor)
Dim sFieldName
Dim vName
Dim lColumnIndex
Dim vID

    sFieldName = UCase(Column.FieldName) ‘ Field you want to look for

    Select Case sFieldName
        Case “ISPRIMARY” ‘ ALIAS name of the column in QB
            lColumnIndex = GetColumnIndexByFieldName ( grdContacts,”NAMELF” ) ‘ Used so that grid can be sorted/grouped
            vName = Node.Values ( lColumnIndex ) ‘ Gets the actual value           

        If Not IsNull ( vName ) Then ‘ Ensure you check for Nulls   

            Select Case ucase(left(vName,1))
                Case “A”
                Color = rgb(255,0,0)
                Font.Bold = True
                FontColor = rgb(0,255,0)
            End Select
        End If
    End Select
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

In the code above we have a case statement that is looking to see if the column of the cell being rendered is the “ISPRIMARY” column. 

    Select Case sFieldName
        Case “ISPRIMARY” ‘ ALIAS name of the column in QB
            lColumnIndex = GetColumnIndexByFieldName ( grdContacts,”NAMELF” ) ‘ Used so that grid can be sorted/grouped
            vName = Node.Values ( lColumnIndex ) ‘ Gets the actual value           
   

If it is it then uses the function GetColumnIndexByFieldName which retruns the column index of a different column we want to find.  In this example we re finding the index position of the “NAMELF” column.  With that index position identified we can then use the Node.Values() function to fetch the value in the column index position specified.

With the Name value having been captured, we can then do something with with it.  In our example we are looking to see if it starts with “A”.  if it does then we are setting things like the Color, Font.Bold, and FontColor.

The end result is a grid with color coding:

 

One last thing.  Suppose you want to get data related to the record but not necessarily in the grid.  Well if you want to get the ID of the record that is being rendered you can use something like this:

 vID = sender.GetCurrentField(sender.KeyField) ‘Gets the primary keyfield of the current row.

 Note: this code does run per cell that is rendered so it can increase the time to render the grid, especially if you are loading a grid with lots of records.

 

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Kris Halsrud
Kris Halsrud
Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

1 COMMENT

  1. Is there a way to force the CustomDrawCell method to be called without having to reload all the data and not call it directly?

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos