Imports Infragistics.Win
Imports Infragistics.Win.SupportDialogs.FilterUIProvider
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim menuSettings As FilterUIProviderMenuSettings = Me.ultraGridFilterUIProvider1.MenuSettings
' Set the default appearance of all tools that are shown by the provider to have a blue background
menuSettings.ToolAppearance.BackColor = Color.Blue
' Show a checked item with a gray background.
menuSettings.CheckedAppearance.BackColor = Color.Gray
End Sub
Private Sub ultraGridFilterUIProvider1_AfterMenuPopulate(ByVal sender As Object, ByVal e As Infragistics.Win.SupportDialogs.FilterUIProvider.AfterMenuPopulateEventArgs)
' Do unique processing for the tools that are on the root level of the menu
For Each tool As FilterTool In e.MenuItems
' Instead of the default gray background on a checked item, have any checked items
' on the root level have a red background.
If tool.Checked Then
tool.CheckedAppearance.BackColor = Color.Red
End If
Dim treeTool As FilterTreeTool = TryCast(tool, FilterTreeTool)
If treeTool IsNot Nothing Then
' Set the tree to only drill down as far as the month of the date. This differs
' from setting the DateHierarchyLevel on the FilterUIProviderTreeSettings in that
' that setting will apply to all menus that the provider shows (as it can be
' associated with multiple grids), while setting the property here allows
' a more precise control over each instance.
treeTool.DateHierarchyLevel = DateHierarchyLevel.Month
Else
' Process any child menu items
Dim menuTool As FilterMenuTool = TryCast(tool, FilterMenuTool)
If menuTool IsNot Nothing Then
Me.AfterMenuPopulateHelper(menuTool.Tools)
End If
End If
Next
End Sub
Private Sub AfterMenuPopulateHelper(ByVal tools As IList(Of FilterTool))
' Prepend the index of each tool to the displayed text
For i As Integer = 0 To tools.Count - 1
Dim tool As FilterTool = tools(i)
tool.DisplayText = String.Format("{0} - {1}", i, tool.DisplayText)
' If the item is the first item in the group, bold the text
if (i = 0 Or tool.IsFirstInGroup)
tool.Appearance.FontData.Bold = DefaultableBoolean.True
' Do this recursively for any other menu tools
Dim menuTool As FilterMenuTool = TryCast(tool, FilterMenuTool)
If menuTool IsNot Nothing Then
Me.AfterMenuPopulateHelper(menuTool.Tools)
End If
Next
End Sub