We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to Show Sort icon

Thread ID:





56659 Feb 19,2007 06:41 AM UTC Feb 19,2007 03:34 PM UTC WinForms 1
Tags: GridControl
Asked On February 19, 2007 06:41 AM UTC


We are using Syncfusion grid for VS.NET 2003.
We have written codes to sort and display the records based on the header in which user clicks. We want to show sort icon (triangle) in the grid header once the user clicks on the header.

Eg : We have a grid with col A, Col B, Col C.

If the user clicks on Col A, the relavent (asc, dec) sort icon should be shown in the header with the colun name


Administrator [Syncfusion]
Replied On February 19, 2007 03:34 PM UTC

Hi Vasanth,

Sorting is directly supported in a GridDataBoundGrid based on the grids through the underlying datatable. For GridControl based grids, the GridControlSort ( \Syncfusion\Essential Studio\\Windows\Grid.Windows\Samples\FeatureSamples\GridControlSort )browser sample will show you how to add header-click sorting to your grid. The header cell draws a sort icon to indicate that the column has been sorted in a particular direction.

There is an inbuilt class, the GridSortColumnHeaderCellModel which, by passing an instance through the CellModels.Add function creates a CellType.

this.gridControl1.CellModels.Add("ColumnHeaderCell", new GridSortColumnHeaderCellModel(this.gridControl1.Model));
this.gridControl1[0, col].CellType = "ColumnHeaderCell";

The direction of the sort icon can be controlled by passing the Ascending or Descending options of the ListSortDirection enumerator through the tag property of the grid.

ListSortDirection dir = ListSortDirection.Ascending;
this.gridControl1[0, col].Tag = dir;

Sorting is done by the Data.SortByColumn function. There are 5 overloads for this function. It also enables comparison through the custom comparer.

this.gridControl1.Data.SortByColumn(col, dir, new FormulaComparer());

A custom comparer class which, derives the IComparer is used to compare the formula values and not the formulas. The FormulaTag.Text property has the formula result and it is used to compare two cells.

Here is a sample.

Best regards,


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon