Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
10660 | Feb 9,2004 05:48 PM UTC | Feb 10,2004 04:32 PM UTC | WinForms | 6 |
![]() |
Tags: GridControl |
this.gridControl1.Data.SortByColumn(col,(ListSortDirection)this.gridControl1[0, col].Tag, 0, cc);
you would call your routine. In your sort routine, you can use whatever technique you want to sort things. It would take a little coding, but can be done. Depending on the size of the grids involved, you might just be able to use grid.Rows.MoveRange to move the rows around. More efficiently, you could use an index array, and just move the indexes during the sorting, and then rearrange the grid once after the sorting is complete. There are many other possibilties as well. public class ComparerClass : IComparer { private DataTable dt; private DataView dv; public ComparerClass(DataTable dt) { this.dt = dt; this.dv = new DataView(dt, "", "", DataViewRowState.CurrentRows); } public int Compare(object x, object y) { GridStyleInfo styleX = new GridStyleInfo(x as GridStyleInfoStore); GridStyleInfo styleY = new GridStyleInfo(y as GridStyleInfoStore); string sx = ""; string sy = ""; dv.RowFilter = string.Format("[id] = {0}", styleX.CellValue); if(dv.Count > 0) { sx = dv[0]["color"].ToString(); } dv.RowFilter = string.Format("[id] = {0}", styleY.CellValue); if(dv.Count > 0) { sy = dv[0]["color"].ToString(); } return sx.CompareTo(sy); } }
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.
This page will automatically be redirected to the sign-in page in 10 seconds.