GrapeCity.Xaml.SpreadSheet.Data
ColumnsSwapped Event
Example 


GrapeCity.Xaml.SpreadSheet.Data Namespace > Worksheet Class : ColumnsSwapped Event
Occurs when two columns are swapped during sorting.
Syntax
'Declaration
 
Public Event ColumnsSwapped As EventHandler(Of ColumnsSwappedEventArgs)
'Usage
 
Dim instance As Worksheet
Dim handler As EventHandler(Of ColumnsSwappedEventArgs)
 
AddHandler instance.ColumnsSwapped, handler
public event EventHandler<ColumnsSwappedEventArgs> ColumnsSwapped
Event Data

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

PropertyDescription
Gets the first column that is swapped during sorting.  
Gets the second column that is swapped during sorting.  
Example
This example uses the ColumnsSwapped 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