Version

Checked Property (FilterTool)

Gets or sets whether the button tool should display a checkmark next to it.
Syntax
'Declaration
 
Public Overridable Property Checked As Boolean
public virtual bool Checked {get; set;}
Remarks

With the exception of a FilterOperandTool, it is the responsibilty of derived classes to determine when they should be considered checked in the menu, since the filter provider does not have a means of determining that filtering has been performed via the click of a tool.

Note: The filter provider does not make an attempt to ensure that only one items is checked at a time. The AfterMenuPopulate event can be used to manipulate which tools are checked.

Example
The following code illustrates how to set the default appearance of tools and then override them for specific tools. Additionally, this code illustrates the process of iterating through all the menu items that will be displayed by the filter provider.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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
using Infragistics.Win;
using Infragistics.Win.SupportDialogs.FilterUIProvider;

private void Form1_Load(object sender, EventArgs e)
{
    FilterUIProviderMenuSettings menuSettings = this.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;
}

private void ultraGridFilterUIProvider1_AfterMenuPopulate(object sender, Infragistics.Win.SupportDialogs.FilterUIProvider.AfterMenuPopulateEventArgs e)
{
    // Do unique processing for the tools that are on the root level of the menu
    foreach (FilterTool tool 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)
            tool.CheckedAppearance.BackColor = Color.Red;

        FilterTreeTool treeTool = tool as FilterTreeTool;
        if (treeTool != null)
        {
            // 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
            FilterMenuTool menuTool = tool as FilterMenuTool;
            if (menuTool != null)
                this.AfterMenuPopulateHelper(menuTool.Tools);
        }
    }
}

private void AfterMenuPopulateHelper(IList<FilterTool> tools)
{
    // Prepend the index of each tool to the displayed text
    for (int i = 0; i < tools.Count; i++)
    {
        FilterTool tool = 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 || tool.IsFirstInGroup)
            tool.Appearance.FontData.Bold = DefaultableBoolean.True;


        // Do this recursively for any other menu tools
        FilterMenuTool menuTool = tool as FilterMenuTool;
        if (menuTool != null)
            this.AfterMenuPopulateHelper(menuTool.Tools);
    }
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also