Spread WPF 15
GrapeCity.Windows.SpreadSheet.Data Namespace / Worksheet Class / ColumnsSwapped Event

In This Topic
    ColumnsSwapped Event
    In This Topic
    Occurs when two columns are swapped during sorting.
    Public Event ColumnsSwapped As EventHandler(Of ColumnsSwappedEventArgs)
    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.

    Gets the first column that is swapped during sorting.  
    Gets the second column that is swapped during sorting.  
    This example uses the ColumnsSwapped event.
    GrapeCity.Windows.SpreadSheet.Data.Worksheet test;
           public MainWindow()
               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)});
           //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)});
    Friend WithEvents test As GrapeCity.Windows.SpreadSheet.Data.Worksheet
        Public Sub New()
            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)
        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)})
            '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)})
        End Sub
    See Also