GrapeCity MultiRow Windows Forms Documentation
SortCompare Event
Example 


Occurs when the GcMultiRow control compares two cell values to perform a sort operation.
Syntax
<SRDescriptionAttribute("Occurs when the GcMultiRow control compares two cell values to perform a sort operation.")>
<SRCategoryAttribute("Data")>
Public Event SortCompare As EventHandler(Of SortCompareEventArgs)
Dim instance As GcMultiRow
Dim handler As EventHandler(Of SortCompareEventArgs)
 
AddHandler instance.SortCompare, handler
[SRDescription("Occurs when the GcMultiRow control compares two cell values to perform a sort operation.")]
[SRCategory("Data")]
public event EventHandler<SortCompareEventArgs> SortCompare
Event Data

The event handler receives an argument of type SortCompareEventArgs containing data related to this event. The following SortCompareEventArgs properties provide information specific to this event.

PropertyDescription
CellIndexGets the cell index in its parent Section.  
CellValue1Gets the value of the first cell to compare.  
CellValue2Gets the value of the second cell to compare.  
Handled (Inherited from System.ComponentModel.HandledEventArgs)
RowIndex1Gets the row index of the first cell to compare.  
RowIndex2Gets the row index that contains the second cell to compare.  
SortResultGets or sets the sort result.  
Remarks

This event occurs only when the DataSource property is not set and the VirtualMode property value is false.

This event compares pairs of cells in two different rows being sorted. It occurs only when you use the ColumnHeaderCell to sort, or when you call the Sort(int) overloaded methods. When this event occurs for a ColumnHeaderCell.SortMode property value of SortMode.Programmatic, you must display the sorting glyph yourself with the ColumnHeaderCell.SortGlyphDirection property.

Example
The following code example shows how to customize complex sort compare logic by handling this event. To run this example, create a GcMultiRow control in a form with a template. The template should contain at least one cell in the row.
void gcMultiRow1_SortCompare(object sender, SortCompareEventArgs e)
        {
            // Customize sort logic by using SortCompare event.
            // Sort by backcolor.

            Color color1 = gcMultiRow1[e.RowIndex1,e.CellIndex].InheritedStyle.BackColor;

            Color color2 = gcMultiRow1[e.RowIndex2, e.CellIndex].InheritedStyle.BackColor;

            e.SortResult =  color1.ToArgb().CompareTo(color2.ToArgb());

            e.Handled = true;
        }
Private Sub gcMultiRow1_SortCompare(ByVal sender As Object, ByVal e As SortCompareEventArgs) Handles gcMultiRow1.SortCompare
        ' Customize sort logic by using SortCompare event.
        ' Sort by backcolor.

        Dim color1 As Color = gcMultiRow1(e.RowIndex1, e.CellIndex).InheritedStyle.BackColor

        Dim color2 As Color = gcMultiRow1(e.RowIndex2, e.CellIndex).InheritedStyle.BackColor

        e.SortResult = color1.ToArgb().CompareTo(color2.ToArgb())

        e.Handled = True
    End Sub
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

GcMultiRow Class
GcMultiRow Members

 

 


Copyright © GrapeCity, inc. All rights reserved.