Articles in this section
Category / Section

How to change the case-sensitive grouping in WinForms GridGroupingControl?

1 min read

Case sensitive grouping

By default, the GridGrouping control groups the column values using case-sensitive comparison. You can change it by using CustomCategorizer in the grouped columns as illustrated in the following code example.

C#

#region Custom Categorizer class
//defines custom categorizer
public class CustomCategorizer : Syncfusion.Grouping.IGroupByColumnCategorizer
{
    public static string GetCategory(string key)
    {
        return key;
    }
    #region IGroupByColumnCategorizer Members
    public object GetGroupByCategoryKey(SortColumnDescriptor column, bool isForeignKey, Record record)
    {
        return GetCategory(record.GetValue(column.Name).ToString());
    }
    public int CompareCategoryKey(SortColumnDescriptor column, bool isForeignKey, object category, Record record)
    {
        return string.Compare(GetCategory(record.GetValue(column.Name).ToString()), (string)category, true);
    }
    #endregion
}

VB

#Region "Custom Categorizer class"
'defines custom categorizer
Public Class CustomCategorizer
    Implements Syncfusion.Grouping.IGroupByColumnCategorizer
    Public Shared Function GetCategory(ByVal key As String) As String
        Return key
    End Function
     #Region "IGroupByColumnCategorizer Members"
     Public Function GetGroupByCategoryKey(ByVal column As SortColumnDescriptor, ByVal isForeignKey As Boolean, ByVal record As Record) As Object
         Return GetCategory(record.GetValue(column.Name).ToString())
     End Function
     Public Function CompareCategoryKey(ByVal column As SortColumnDescriptor, ByVal isForeignKey As Boolean, ByVal category As Object, ByVal record As Record) As Integer
         Return String.Compare(GetCategory(record.GetValue(column.Name).ToString()), CStr(category), True)
     End Function
     #End Region
End Class

The following screenshot illustrates the Grid after grouping ship columns.

Show grouping ship column

Figure 1: Grouping Ship column

The following screenshot illustrates the Grid after grouping the samples.

Show grouping ship and amount column

Figure 2: Grouping Ship and Amount column

Samples:

C#: Case sensitive

VB: Case sensitive

Reference link: https://help.syncfusion.com/windowsforms/gridgrouping/grouping#custom-grouping

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied