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

DataboundGrid BeginUpdate is not suspending painting in custom sorting

Thread ID:





7583 Oct 1,2003 04:21 PM UTC Oct 3,2003 08:33 PM UTC WinForms 3
Tags: GridControl
Administrator [Syncfusion]
Asked On October 1, 2003 04:21 PM UTC

Hi, In my databound grid, when the user double clicks on a column, I want to use my own custom sorting method. So I created a hidden column "SortOrder" and changing the values in that column everytime the user double clicks on a col header. After that I use currencymanager and bindinglist to sort it. In the attached sample, I have derived from DataboundGrid( VS.NET 2003) and it has datatable (which is part of a dataset) as the datasource. I have overridden the SortColumn(int colIndex) method from base class. I cut/pasted SortField() code from the Syncfusion databound grid. I commented out BinderSort(fieldNum) and added my sorting logic there. In my sorting logic, I am updating DataRow["SortOrder"] values. Run the attached sample, keep double clicking on the name column to see the values scrolling. I want to suppress the painting until sorting is completed. Eventhough I have BeginUpdate() and EndUpdate() around my code, why is the grid painting? Also, Is there anyway to show the sort icon on current column header even though I am sorting on "SortOrder" column? thanks, - Reddy

Administrator [Syncfusion]
Replied On October 3, 2003 03:47 PM UTC

Call SuspendBinding after BeginUpdate and ResumeBinding after EndUpdate: /// public override void SortColumn(int colIndex) { bool hasCC = CurrentCell.HasCurrentCell; //int colIndex = CurrentCell.ColIndex; BeginUpdate(); this.Binder.SuspendBinding(); try { int fieldNum = this.Binder.ColIndexToField(colIndex); Console.WriteLine("Customer Sorting fieldNum = " + fieldNum); if (CommitChanges()) { CollapseAll(); //Binder.Sort(fieldNum); // use custom sorting string fieldName = this.Binder.InternalColumns[fieldNum].MappingName; DataTable table = this.DataSource as DataTable; SortTable(fieldName, table, GetSortDirection()); Selections.Clear(); Refresh(); if (hasCC) { CurrentCell.MoveTo(Binder.CurrentRowIndex, colIndex); } } } finally { this.Binder.ResumeBinding(); EndUpdate(); } } BTW - I recently worked on a similar example so that you can sort a databound grid with the foreign key of a combobox displaymember. I'll attach it although it looks like you already got it working your way. But maybe it still helps. Stefan

Administrator [Syncfusion]
Replied On October 3, 2003 07:17 PM UTC

Stefan, Thank you very much for your reply. Now my painting problem is gone. I have a complex tree sorting that can not be done using the datasource technique you mentioned above. How can I show the little sort direction icon in my header cell on which the user double clicked (even through I am actually sorting based on a hidden column 'SortOrder')? I tried setting this[0, curColIndex].Tag = ListSortDireciton.Ascending. It does not work. thanks, - Reddy

Administrator [Syncfusion]
Replied On October 3, 2003 08:33 PM UTC

You need to do that in QueryCellInfo. Check out the QueryCellInfo code in the sample. You should do something similar. 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