FlexGrid for WinForms
CustomComparer Property
Example 



Gets or sets a custom comparer object used by the grid to perform grouping, merging, and searching operations.
Syntax
'Declaration
 
<BrowsableAttribute(False)>
<DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)>
Public Property CustomComparer As IComparer
'Usage
 
Dim instance As C1FlexGridBase
Dim value As IComparer
 
instance.CustomComparer = value
 
value = instance.CustomComparer
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IComparer CustomComparer {get; set;}
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public:
property IComparer^ CustomComparer {
   IComparer^ get();
   void set (    IComparer^ value);
}
Remarks

The grid has a default System.Collections.IComparer implementation that is used to compare cells and determine if their contents are equivalent. This implementation is used when merging, grouping, or searching for values (see the AllowMerging property and the Subtotal(AggregateEnum,Int32,Int32,Int32,Int32,String) and FindRow(String,Int32,Int32,Boolean,Boolean,Boolean,Boolean) methods).

The default implementation is case-sensitive and takes leading and trailing blanks into account.

If you want to merge cells using a case-insensitive comparison or trimming blanks, write a custom class that implements the System.Collections.IComparer interface and assign an instance of it to the grid's CustomComparer property.

Setting this property to null (Nothing in Visual Basic) restores the default behavior.

Example
The code below replaces the built-in comparer with a System.Collections.CaseInsensitiveComparer. This causes the Subtotal(AggregateEnum,Int32,Int32,Int32,Int32,String) method to group items that differ only in case into the same groups:
// use case-insensitive comparer
flex.CustomComparer = new CaseInsensitiveComparer(); 
            
// add groups ignoring case
flex.Subtotal(AggregateEnum.Sum, 0, groupOn, totalOn);
            
// restore default (case-sensitive) comparer
flex.CustomComparer = null;
Requirements

Target Platforms: 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

Reference

C1FlexGridBase Class
C1FlexGridBase Members

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Send Feedback