GridView Data Sorting in C#
The Kettic GridView .NET component provides a SortDescriptors property for users to set the grid data sorting function. This property is at the level of GridViewTemplate that is exposed in KetticGridView C# class for MasterTemplate instance. The descriptors for sorting allow users to create grid data sorting property and grid data sorting direction. The descriptor is a collection so that users just need perform the delete or clear operation. The collection is able to sort grid data of the descriptor that has been newly added.
How to Create Data Sorting to GridView
The sorting functionality can be enabled through the SortDescriptor property. We need change the value of the EnableSorting property of the desired template to True. The simple C# code below demonstrates how to achieve this.
And then, we can create and add new SortDescriptor to the collection to create grid data sorting for GridView. In the C# code below, we are going to use the PropertyName and the SortDirection properties. The PropertyName property will determine the sorting of grid data and the SortDirection property will control the sort direction.
How to Sort Grid Data by Multiple Columns
The Kettic DataGridView component is capable of sorting grid data not only by one column, but also multiple columns. The C# code below shows how to sort grid data by two columns to GridView. In the example below, the GridView will sort the ProductName column first as this sort expressions are added first, and then sort all groups based on the Price.
|
UI Controlsfor Windows Forms .NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI DesignWinForms UI Controls WinForms Buttons UI Control WinForms Calendar UI ControlWinForms Carousel UI ControlWinForms Chart UI ControlWinForms Clock UI ControlCommandBar UI ControlWinForms Dock UI ControlDesktop Alert UI ControlDropDown List UI ControlWinForms Editor UI ControlForms and Dialogs UI ControlWinForms GridView UI ControlGridView - Get Started in C#GridView - PropertiesGridView - ColumnGridView - RowGridView - CellsGridView - EditorsGridView - Context MenuGridView - Populating with DataGridView - Hierarchical GridData Binding AutomaticallyData Binding ProgrammaticallyXML Data SourceResize Child GridVieInfoOne to Many RelationsExpand RowsGridView - SelectionBasic SelectionMultiple SelectionProgrammatical Rows & Cells Selection GridView - ScrollingGridView - SortingSet ProgrammaticallySorting ExpressionsGridView - GroupingGridView - FilteringGridView - Expression EditorInsert/ Update/ Delete RecordsGridView - View DefinitionGridView - Exporting DataStyling and AppearanceGridView - LocalizationSave and Load LayoutGridView - Print SupportWinForms ListView UI ControlWinForms Menu UI ControlWinForms ComboBox UI ControlWinForms PageView UI ControlPanels and Labels UI ControlWinForms Panorama UI ControlWinForms PDFViewer UI ControlWinForms Property Grid UI ControlWinForms Ribbon UI ControlWinForms PivotGrid UI ControlWinForms RichTextBox UI ControlWinForms Rotator UI ControlWinForms Scheduler UI ControlWinForms Shortcuts UI ControlWinForms SpellChecker UI ControlWinForms Track & Status UI ControlWinForms TreeView UI ControlWinForms Wizard UI ControlWinForms Test UI ControlWinForms Theme UI Control |