FlexGrid for WinForms
Step 3 of 4: Allow Automatic Sorting
Show AllShow All
Hide AllHide All

The first step in organizing the data is sorting it. Furthermore, we would like the data to be sorted automatically whenever the user reorders the columns.

After the user reorders the columns, the C1FlexGrid control fires the AfterDragColumn event. We will add an event handler to sort the data in the underlying data table. (If the grid were being used in unbound mode, we would accomplish this using the Sort method.)

Add the following code to the form to sort the record set and rebuild the subtotals when the user drags columns:

To write code in Visual Basic

To write code in C#

Run the program and observe the following:

Run the project and try reordering the first three columns by dragging their headings around. Whenever you move a column, the data is automatically sorted, which makes it easier to interpret.


In the next step, we will add subtotals and an outline tree.

See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback