Home Forums WinForms controls Xceed Grid for WinForms Custom grouping and sorting

Viewing 1 post (of 1 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #17801 |

    This example demonstrates how to create a custom group description by deriving from the DataGridGroupDescription class and overriding the GroupNameFromItem method. The custom group description will group items according to the first letter in the value received as a parameter.

    The implementation for the custom sort comparer assigned to the group description’s SortComparer property is provided below.


    Imports System
    Imports System.Collections.Generic
    Imports System.Text
    Imports Xceed.Wpf.DataGrid
    Imports System.Collections
    Imports System.Globalization;

    Namespace Xceed.Wpf.Documentation
      Public Class AlphabeticalGroupDescription
             Inherits DataGridGroupDescription

        Public Sub New()
        End Sub

        Public Sub New(ByVal propertyName As String)
        End Sub

        Public Overrides Function GroupNameFromItem(ByVal item As Object, _
                                                    ByVal level As Integer, _
                                                    ByVal culture As CultureInfo) As Object
          Dim value As Object = MyBase.GroupNameFromItem(item, level, culture)
            Dim content As String = Convert.ToString(value)
            value = content.ToUpper().Substring(0, 1)
          Catch e1 As InvalidCastException
          End Try

          Return value
        End Function
      End Class
    End Namespace


    using System;
    using System.Collections.Generic;
    using System.Text;
    using Xceed.Wpf.DataGrid;
    using System.Collections;

    namespace Xceed.Wpf.Documentation
      public class AlphabeticalGroupDescription : DataGridGroupDescription
        public AlphabeticalGroupDescription()
          : base()

        public AlphabeticalGroupDescription( string propertyName )
          : base( propertyName )
        public override object GroupNameFromItem( object item, int level,
                                                  System.Globalization.CultureInfo culture )
          object value = base.GroupNameFromItem( item, level, culture );
            string content = Convert.ToString( value );

    Imported from legacy forums. Posted by Xceed admin (had 1341 views)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.