Spread WPF Documentation
RowsSwapped Event
Example 


Occurs when two rows are swapped during sorting.
Syntax
'Declaration
 
Public Event RowsSwapped As System.EventHandler(Of RowsSwappedEventArgs)
'Usage
 
Dim instance As Worksheet
Dim handler As System.EventHandler(Of RowsSwappedEventArgs)
 
AddHandler instance.RowsSwapped, handler
public event System.EventHandler<RowsSwappedEventArgs> RowsSwapped
Event Data

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

PropertyDescription
Row1Gets the first row that is swapped during sorting.  
Row2Gets the second row that is swapped during sorting.  
Example
This example uses the RowsSwapped event.
GrapeCity.Windows.SpreadSheet.Data.Worksheet test;
     
       public MainWindow()
       {
           InitializeComponent();
           test = GcSpreadSheet1.ActiveSheet;
           test.ColumnsSwapped += testColumnsSwapped;
           test.RowsSwapped += testRowsSwapped;

           for (int i = 0; i <= 9; i++)
           {
               for (int j = 0; j <= 4; j++)
               {
                   GcSpreadSheet1.Sheets[0].SetValue(i, j, i);
               }
           }
       }

       private void testColumnsSwapped(object sender, GrapeCity.Windows.SpreadSheet.Data.ColumnsSwappedEventArgs e)
       {
           TextBox1.Text = e.Column1.ToString();
       }

       private void testRowsSwapped(object sender, GrapeCity.Windows.SpreadSheet.Data.RowsSwappedEventArgs e)
       {
           TextBox1.Text = e.Row1.ToString();
       }

       private void button1_Click_1(object sender, RoutedEventArgs e)
       {
        //Sort by rows
        GcSpreadSheet1.Sheets[0].SortRange(0, 0, 10, 5, true, new GrapeCity.Windows.SpreadSheet.Data.SortInfo[] {new GrapeCity.Windows.SpreadSheet.Data.SortInfo(0, false)});
        GcSpreadSheet1.Invalidate();
       //Sort by columns
       //GcSpreadSheet1.Sheets[0].SortRange(0, 0, 10, 5, false, new GrapeCity.Windows.SpreadSheet.Data.SortInfo[] {new GrapeCity.Windows.SpreadSheet.Data.SortInfo(0, false)});
       //GcSpreadSheet1.Invalidate();
       }
Friend WithEvents test As GrapeCity.Windows.SpreadSheet.Data.Worksheet

    Public Sub New()
        InitializeComponent()
        test = GcSpreadSheet1.ActiveSheet
        AddHandler test.ColumnsSwapped, AddressOf testColumnsSwapped
        AddHandler test.RowsSwapped, AddressOf testRowsSwapped

        For i As Integer = 0 To 9
            For j = 0 To 4
                GcSpreadSheet1.Sheets(0).SetValue(i, j, i)
            Next
        Next
    End Sub

    Private Sub testColumnsSwapped(sender As Object, e As GrapeCity.Windows.SpreadSheet.Data.ColumnsSwappedEventArgs) Handles test.ColumnsSwapped
        TextBox1.Text = e.Column1.ToString()
    End Sub

    Private Sub testRowsSwapped(sender As Object, e As GrapeCity.Windows.SpreadSheet.Data.RowsSwappedEventArgs) Handles test.RowsSwapped
        TextBox1.Text = e.Row1.ToString()
    End Sub

Private Sub button1_Click(sender As Object, e As RoutedEventArgs) Handles button1.Click
        'Sort by rows
         GcSpreadSheet1.Sheets(0).SortRange(0, 0, 10, 5, True, New GrapeCity.Windows.SpreadSheet.Data.SortInfo() {New GrapeCity.Windows.SpreadSheet.Data.SortInfo(0, False)})
         GcSpreadSheet1.Invalidate()
        'Sort by columns
        'GcSpreadSheet1.Sheets(0).SortRange(0, 0, 10, 5, False, New GrapeCity.Windows.SpreadSheet.Data.SortInfo() {New GrapeCity.Windows.SpreadSheet.Data.SortInfo(0, False)})
        'GcSpreadSheet1.Invalidate()
    End Sub

Requirements

Target Platforms: Windows 7, Windows 8 Desktop, Windows Vista SP1 or later, Windows Server 2000, Windows 2000 Professional (SP4), Windows XP (SP2), Windows 2008, Windows 2003 Server (SP1)

See Also

Reference

Worksheet Class
Worksheet Members

 

 


Copyright © GrapeCity, inc. All rights reserved.