ADAdministrator Syncfusion Team February 23, 2005 10:01 AM
There are several ways to approach this. One is to derive your own cell type and use it for the sorted column headers. The sample, \Syncfusion\Essential Suite\22.214.171.124\Windows\Grid.Windows\Samples\Quick Start\GridControlSort\, shows how you can control the column header or a sorted column, specifying the CellType for that column. That sample uses teh default "ColumnHeaderCell" celltype to control the look of teh cell. You would want to replace this with you own celltype.
Something that might be simpler is to handle the CellDrawn event, and there you could just overdraw the sort bitmap with one of your choosing. Here is a forum thread that discusses how to overpaint the triangle in the current row header cell. You could try something similar with the sorted column header. To id the sorted column header, you can check the style.Tag for the cell is a ListSortDirection value or not.
ADAdministrator Syncfusion Team February 23, 2005 10:47 AM
Where is the thread ?
ADAdministrator Syncfusion Team February 23, 2005 10:49 AM
Also when allowing colum dragging, there is a conflict with the sorting.
Because the click is handled by both event.
How to overcome this problem ?
ADAdministrator Syncfusion Team February 23, 2005 11:09 AM
Here is the first link.
One way to handle the second question is to set the SortBehavior property to DoubleClick. If you do not want to do this, here is another is another thread with a different solution.
ADAdministrator Syncfusion Team February 23, 2005 11:39 AM
The example of the first trade triggers an exception with a gridcontrol...
ADAdministrator Syncfusion Team February 23, 2005 12:02 PM
I do not know what that means.
Can you upload a sample showing the problem you are having (or send it to email@example.com and mention this thread in the subjext line)?
ADAdministrator Syncfusion Team February 23, 2005 12:34 PM
I found the problem.
But the icon is in the middle of the cell shadowing the header name:
private void _grid_CellDrawn(object sender, GridDrawCellEventArgs e)
if(e.ColIndex > 0 && e.RowIndex == 0)
Rectangle rect = GridUtil.CenterInRect(e.Bounds, this._imageList.ImageSize);
GridStaticCellRenderer.DrawImage(e.Graphics, this._imageList, 0, rect);
How do you check the tag and how do you know if we are sorting in this column ?
ADAdministrator Syncfusion Team February 23, 2005 01:26 PM
You get the Tag from the style object for the cell.
object tag = grid[r.RowIndex, e.ColIndex].Tag;
The grid actually uses OnDrawCellDisplayText to draw the sort header. Here is the code it uses to decide where to draw it.
protected override void OnDrawDisplayText(Graphics g, Rectangle textRectangle, int rowIndex, int colIndex, GridStyleInfo style)
// No arrow needed when printing.
object tag = style.Tag;
if (Grid.PrintingMode || !(tag is ListSortDirection))
tag = null;
ListSortDirection listSortDirection = ListSortDirection.Ascending;
int margin = 0;
if (tag != null)
listSortDirection = (ListSortDirection) tag;
margin = 12;
GridUtil.OffsetLeft(ref textRectangle, margin);
textRectangle.Width -= margin;
base.OnDrawDisplayText(g, textRectangle, rowIndex, colIndex, style);
if (tag != null)
rect = new Rectangle(textRectangle.Left-margin, textRectangle.Y, 10, textRectangle.Height);
rect = new Rectangle(textRectangle.Right, textRectangle.Y, 10, textRectangle.Height);
rect = GridUtil.CenterInRect(rect, new Size(8, 8));
Brush brush = new SolidBrush(SystemColors.ControlDark);
int i2 = Math.Max(0, (rect.Height - 3) / 2);
Pen pen1 = new Pen(SystemColors.WindowFrame);
Pen pen2 = new Pen(SystemColors.Control);
GridTriangleDirection triangleDirection = listSortDirection == ListSortDirection.Ascending ? GridTriangleDirection.Up : GridTriangleDirection.Down;
GridPaintTriangle.Paint(g, rect, triangleDirection, brush, pen1, true);