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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Databound Grid Column Sorting

Thread ID:





1489 Nov 4,2002 03:23 PM UTC Nov 4,2002 05:41 PM UTC WinForms 1
Tags: GridControl
Anthony Mansfield
Asked On November 4, 2002 03:23 PM UTC

Is there a way to determine which column is currently sorted and if it is sorted ascending/descending? I have a databound grid that is refreshed based on other form events. Each time the grids datasourece is updated I am calling the ColumnSort(1) to ensure that the grid is sorted. This is causing the grid to toggle between an ascending and descending sort, even though the data has been refreshed. I thought about checking to see if it is currently sorted and then only sorting if needed, but I could not find a way to determine if it was sorted. Should the sort be maintained, even though the datasource has changed? Thanks - Anthony

Stefan Hoenig [Syncfusion]
Replied On November 4, 2002 05:41 PM UTC

Hi Anthony, the following methods should let you do all the sorting directly on the underlying datasource: public static ListSortDirection GetSortDirection(IList list) { if (list is IBindingList && ((IBindingList)list).SupportsSorting) return ((IBindingList)list).SortDirection; return ListSortDirection.Ascending; } public static PropertyDescriptor GetSortProperty(IList list) { if (list is IBindingList && ((IBindingList)list).SupportsSorting) return ((IBindingList)list).SortProperty; return null; } public static void SetSort(IList list, PropertyDescriptor property, ListSortDirection sortDirection) { if (list is IBindingList && ((IBindingList)list).SupportsSorting) ((IBindingList)list).ApplySort(property, sortDirection); } public static bool SupportsSort(IList list) { return list is IBindingList && ((IBindingList)list).SupportsSorting; } I'll make a note that the Sort method in the GridModelDataBinder should accept a SortDirection. Stefan


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

Live Chat Icon For mobile
Live Chat Icon