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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Perfomance of column sorting

Thread ID:





12393 Mar 29,2004 09:18 AM UTC Mar 30,2004 09:56 AM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On March 29, 2004 09:18 AM UTC

I am sorting on three columns with following code: private void gridControlTerminals_CellClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e) { if(e.MouseEventArgs.Button == MouseButtons.Left && e.RowIndex == 0 && e.ColIndex > 0) { gridTerminalSortColumn(e.ColIndex); } } private void gridTerminalSortColumn(int col) { //If the user presses two times on same column it will //be sorted in opposit direction if( col == lastColSorted ) { if ( newDirection == System.ComponentModel.ListSortDirection.Ascending ) { gridControlTerminals.Data.SortByColumn(col, System.ComponentModel.ListSortDirection.Ascending); gridControlTerminals.Refresh(); //Save the direction newDirection = System.ComponentModel.ListSortDirection.Descending; } else { gridControlTerminals.Data.SortByColumn(col, System.ComponentModel.ListSortDirection.Descending); gridControlTerminals.Refresh(); //Save the direction newDirection = System.ComponentModel.ListSortDirection.Ascending; } } else { gridControlTerminals.Data.SortByColumn(col, System.ComponentModel.ListSortDirection.Ascending); gridControlTerminals.Refresh(); newDirection = System.ComponentModel.ListSortDirection.Ascending; } //Save this columnnr lastColSorted = col; } } When i try to shift direction on the same column it lacks so it wont shift direction every time. My guess is that i dont get the mouseevent when the grid is sorting. I noticed the same problem ocures in the SyncFusion GridControlExample. Is there a faster method of sorting the columns? The problem doesnt ocur when i sort different columns every time... Thanks! Kristian Bang, Denmark

Administrator [Syncfusion]
Replied On March 29, 2004 11:08 AM UTC

You might be able to discourage your user from trying to initiate a new sort before the current sort is completed by putting up a wait cursor around the sort call. this.Cursor = Cursors.WaitCursor; this.gridControl1.Data.SortByColumn(col,(ListSortDirection)this.gridControl1[0, col].Tag); this.Cursor = Cursors.Default; As far as faster sorting, if you have special knowledge of the data, then you might be able to do something faster by writing your own SortByColumn implementation, or maybe calling an overload of SortByColumn that accepts a custom comparer object that makes use of the special knowledge. The grid essentially does an ArrayList.Sort call. We will look at the default sort action to see if there is something we can do to speed it up.

Administrator [Syncfusion]
Replied On March 30, 2004 09:56 AM UTC

Isn''t it a bit weird that it is fast enough when i choose to sort a different cloumn every time? I have strings in all three columns so i doubt i can do it faster than an array.Sort()... Until i find a way to get more stability i''ll only sort ascending and not shift direction. Kristian


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