)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: GridGroupingControl |
Published Date: November 28, 2014 |
Last Revised Date: February 13, 2020
Tags: grouping

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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon