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

saving the sort

Thread ID:





60590 May 8,2007 05:44 PM UTC May 9,2007 08:13 PM UTC WinForms 4
Tags: GridControl
Charlie Mao
Asked On May 8, 2007 05:44 PM UTC


I was wondering if there is a way to grab the way a grid has been sorted. Currently, when i clear out the grid using grid.GridBoundColumns.Clear(); the sort also gets cleared out. Can I grab how the grid is sorted, clear out the grid, and redraw the new grid with the same sort?


Saravanan A [Syncfusion]
Replied On May 8, 2007 07:11 PM UTC

Hi Charlie,

Please refer to the following forum threads that will help you to get the sorted order.

See the last thread in this forum.http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=12261

Using these information you can reapply the same sorting, programmatically after changing the datasource.
Here is the code snippet to apply sorting programmatically.

CurrencyManager cm = this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource,
this.gridDataBoundGrid1.DataMember] as CurrencyManager;
if(cm != null)
int colIndex = this.gridDataBoundGrid1.Binder.ColIndexToField(2);
string colName = this.gridDataBoundGrid1.Binder.InternalColumns[colIndex].MappingName;

DataView dv = cm.List as DataView;
dv.Sort = string.Format("[{0}] DESC", colName);

Best Regards,

Charlie Mao
Replied On May 8, 2007 08:01 PM UTC

Hi Saravanan,

Thanks for the reply. This code snippets seems to apply the sort programmatically for the second column descending. What if the user changes the sort to another column, can you catch that change and apply it programmatically.


Saravanan A [Syncfusion]
Replied On May 9, 2007 01:14 AM UTC

Hi Charlie,

Please refer to the following sample, in which the sorting order is retained while reinitializing the datasource.

Sample: http://websamples.syncfusion.com/samples/Grid.Windows/F60590/main.htm

Best Regards,

Charlie Mao
Replied On May 9, 2007 08:13 PM UTC

Hi Saravanan,

Thank you so much. This worked great.



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.

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.