GrapeCity.Xaml.SpreadSheet.Data
RowsSwapped Event
Example 


GrapeCity.Xaml.SpreadSheet.Data Namespace > Worksheet Class : RowsSwapped Event
Occurs when two rows are swapped during sorting.
Syntax
'Declaration
 
Public Event RowsSwapped As EventHandler(Of RowsSwappedEventArgs)
'Usage
 
Dim instance As Worksheet
Dim handler As EventHandler(Of RowsSwappedEventArgs)
 
AddHandler instance.RowsSwapped, handler
public event 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
Gets the first row that is swapped during sorting.  
Gets the second row that is swapped during sorting.  
Example
This example uses the RowsSwapped event.
GrapeCity.Xaml.SpreadSheet.Data.Worksheet test;

       public MainPage()
       {
           this.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.Xaml.SpreadSheet.Data.ColumnsSwappedEventArgs e)
       {
           TextBox1.Text = e.Column1.ToString();
       }

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


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

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

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

    Private Sub Grid_Loaded_1(sender As Object, e As RoutedEventArgs)
        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 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.Xaml.SpreadSheet.Data.SortInfo() {New GrapeCity.Xaml.SpreadSheet.Data.SortInfo(0, False)})
        GcSpreadSheet1.Invalidate()
        'Sort by columns
        'GcSpreadSheet1.Sheets(0).SortRange(0, 0, 10, 5, False, New GrapeCity.Xaml.SpreadSheet.Data.SortInfo() {New GrapeCity.Xaml.SpreadSheet.Data.SortInfo(0, False)})
        'GcSpreadSheet1.Invalidate()       
    End Sub
See Also