GrapeCity MultiRow Windows Forms Documentation
Sort(String,SortOrder) Method
Example 


The name of the cell by which to sort the contents of the GcMultiRow control.
The sort order.
Sorts the contents of the GcMultiRow control using an implementation of the IComparer interface.
Syntax
Public Overloads Sub Sort( _
   ByVal cellName As String, _
   ByVal sortOrder As SortOrder _
) 
Dim instance As GcMultiRow
Dim cellName As String
Dim sortOrder As SortOrder
 
instance.Sort(cellName, sortOrder)
public void Sort( 
   string cellName,
   SortOrder sortOrder
)

Parameters

cellName
The name of the cell by which to sort the contents of the GcMultiRow control.
sortOrder
The sort order.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionThe cellName is a null reference (Nothing in Visual Basic) or String.Empty.
System.ArgumentExceptionThe cellName does not match the name of any Cell in the Row.
System.ComponentModel.InvalidEnumArgumentExceptionThe sortOrder is an invalid value for the System.Windows.Forms.SortOrder enumeration.
System.InvalidOperationException

This method cannot be accessed when the Template is a null reference (Nothing in Visual Basic).

-or-

VirtualMode is true and DataSource is a null reference (Nothing in Visual Basic).

Remarks

This method sorts the contents of the GcMultiRow control by comparing values in the specified cells with the same cell index. By default, the sort operation uses the System.Collections.Comparer.Compare(System.Object,System.Object) method to compare pairs of cells by using the Value property.

You can write an event handler for the CellMouseClick event for ColumnHeaderCell and call this method. In this case, you typically set the SortMode property to SortMode.Programmatic to disable automatic sorting and to leave room for a sorting glyph. When sorting by cells set to programmatic sort mode, you must display the sorting glyph yourself by setting the SortGlyphDirection property.

If the AllowUserToAddRows property value is true, the last row is always the last row. In this case, the sorting operator does not effect the last row (uncommitted new row).

Example
The following code example shows how to sort GcMultiRow. 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. You can call this method in a button click event handler or form load event. The first cell is sorted in ascending order.
void SortByCode()
        {
            // Sort first cell of all rows.
            this.gcMultiRow1.Sort(test, SortOrder.Ascending);
        }
Private Sub SortByCode()
        ' Sort first cell of all rows.
        Me.gcMultiRow1.Sort(test,SortOrder.Ascending)
    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
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.