Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Customizing Row or Column Interaction / Managing Filtering of Rows of User Data / Customizing Simple Filtering / Customizing the Filter List / Defining the Order of the Items in the Filter Item List
In This Topic
    Defining the Order of the Items in the Filter Item List
    In This Topic

    You can customize how the drop-down list of filter items is displayed. By default, the list shows the possible filter items alphabetically and includes all the options. By changing the value of the FilterListBehavior enumeration, you change how the filter list is displayed. For example you can set the filter list to display items in order of number of occurrences in that column.

    Use the AddColumn methods and specify the column filter definition. This also defines the way the filter items appear in the drop-down.

    Using Code

    Set the FilterListBehavior enumeration to change how the filter list is displayed.

    Example

    The following example illustrates setting the FilterListBehavior enumeration in code.

    C#
    Copy Code
    FarPoint.Win.Spread.NamedStyle instyle = new FarPoint.Win.Spread.NamedStyle();
    FarPoint.Win.Spread.NamedStyleim outstyle = new FarPoint.Win.Spread.NamedStyle();
    instyle.BackColor = Color.Yellow;
    outstyle.BackColor = Color.Aquamarine;
    FarPoint.Win.Spread.FilterColumnDefinition fcd = new FarPoint.Win.Spread.FilterColumnDefinition(1, FarPoint.Win.Spread.FilterListBehavior.SortByMostOccurrences | FarPoint.Win.Spread.FilterListBehavior.Default);
    FarPoint.Win.Spread.FilterColumnDefinition fcd1 = new FarPoint.Win.Spread.FilterColumnDefinition(2);
    FarPoint.Win.Spread.FilterColumnDefinition fcd2 = new FarPoint.Win.Spread.FilterColumnDefinition();
    FarPoint.Win.Spread.StyleRowFilter sf = new FarPoint.Win.Spread.StyleRowFilter(fpSpread1.ActiveSheet, instyle, outstyle);
    sf.AddColumn(fcd);
    sf.AddColumn(fcd1);
    sf.AddColumn(fcd2);
    fpSpread1.ActiveSheet.RowFilter = sf;
    fpSpread1.ActiveSheet.AutoFilterMode = FarPoint.Win.Spread.AutoFilterMode.FilterGadget;
    
    VB
    Copy Code
    Dim instyle As New FarPoint.Win.Spread.NamedStyle
    Dim outstyle As New FarPoint.Win.Spread.NamedStyle
    instyle.BackColor = Color.Yellow
    outstyle.BackColor = Color.Aquamarine
    Dim fcd As New FarPoint.Win.Spread.FilterColumnDefinition(1, FarPoint.Win.Spread.FilterListBehavior.SortByMostOccurrences Or FarPoint.Win.Spread.FilterListBehavior.Default)
    Dim fcd1 As New FarPoint.Win.Spread.FilterColumnDefinition(2)
    Dim fcd2 As New FarPoint.Win.Spread.FilterColumnDefinition
    Dim sf As New FarPoint.Win.Spread.StyleRowFilter(fpSpread1.ActiveSheet, instyle, outstyle)
    sf.AddColumn(fcd)
    sf.AddColumn(fcd1)
    sf.AddColumn(fcd2)
    fpSpread1.ActiveSheet.RowFilter = sf
    fpSpread1.ActiveSheet.AutoFilterMode = FarPoint.Win.Spread.AutoFilterMode.FilterGadget
    
    See Also