ComponentOne FlexGrid for WinForms
Undoing a Sort
FlexGrid for WinForms Task-Based Help > Undoing a Sort

To undo a sort in C1FlexGrid when the grid is bound to a DataTable, set the DefaultView property to null.

Add the following code to the Button1_Click event:

To write code in Visual Basic

Visual Basic
Copy Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    CustTable.DefaultView.Sort = ""
End Sub

To write code in C#

C#
Copy Code
private void Button1_Click(object sender, System.EventArgs e)
{
    CustTable.DefaultView.Sort = "";
}
Note: The DataTable.DefaultView returns the DataView of the DataTable, and setting the sort string to null forces the DataView to undo the previous sort.

This topic illustrates the following:

Click the Last Name column to sort on it.


Click the Undo button, and the sort will be undone.


See Also