Disabling an Editable Field in a Datagrid in SalesLogix v7

Question: I’m trying to disable an editable date field in a datagrid in SalesLogix v7 using this code:

from the CustomDrawCell event – the field name and
display name are ‘Online_Date’ and grid is named dgProduction:


I get the error:
Object Required: ‘dgProduction.Columns.Item(…)’

I’ve used this code before without issue.  Any thoughts why this is happening?

Answer:  Issues with the name/caption and sorting (when you click a sort column you’ll get errors) can be avoided by using this code:

Colouring a grid

the Grid – select the property “OnCustomDrawCell” – this will create a
sub based on the name of the grid followed by CustomDrawCell e.g.

Sender, ByRef Node, ByRef Column, IsSelected,
IsFocused, ByRef Text, ByRef Color, ByRef Alignment, ByRef Font, ByRef

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
GetColumnIndexByFieldName = lColumnIndex
End Function

Put in your options during the Case item.


Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!