Hello,
I'm setting the TAG property so I can check the existence of a FormatCondition by the TAG which is one of the overloads in the FormatConditions method. I've tried several variations of this code but cannot seem to get the Dim cond= line to ever be "not nothing" i.e. found the condition by the tag property. Please verify and see if this is a bug. Thank you.
Private Sub CreateUserFormatConditions()
If Not My.Settings.HighlightLowActivityUsers Then
Return
End If
If Not HasLowActivityFormatCondition() Then
Dim inactiveUserCondition As New DevExpress.XtraTreeList.StyleFormatConditions.StyleFormatCondition
With inactiveUserCondition
.Appearance.ForeColor = System.Drawing.Color.Red
.Appearance.Options.UseForeColor = True
.ApplyToRow = True
.Column = Me.colLastLoginUtc
.Condition = DevExpress.XtraGrid.FormatConditionEnum.LessOrEqual
.Value1 = DateTime.Now.AddDays(-60)
.Tag = "activitymonitor"
Me.treeUsers.FormatConditions.AddRange(New DevExpress.XtraTreeList.StyleFormatConditions.StyleFormatCondition() {inactiveUserCondition})
End With
End If
End Sub
Private Sub RemoveUserFormatConditions()
If HasLowActivityFormatCondition() Then
Dim cond = treeUsers.FormatConditions("activitymonitor")
treeUsers.FormatConditions.Remove(cond)
End If
End Sub
Private Function HasLowActivityFormatCondition() As Boolean
Dim cond = treeUsers.FormatConditions("activitymonitor") '<---this is what is not working, it's always NOTHING
Return (cond IsNot Nothing)
'Return (treeUsers.FormatConditions.Count > 1)
End Function