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.
Unfortunately, activation email could not send to your email. Please try again.

GridGroupingControl - Sort Arrow Change

Thread ID:

Created:

Updated:

Platform:

Replies:

63142 Jun 28,2007 12:42 PM Jun 29,2007 07:22 PM Windows Forms 3
loading
Tags: Grouping
Badri Rajani Kanth
Asked On June 28, 2007 12:42 PM

Hi,

We are using V 4.2.0.37

When we simple/group sort any columns, currently arrow is displayed in column name. i just want to reverse the arrow. Say, I want ASC ->Down Arrow, DESC -> UP Arrow.

How can I do this?

Thanks & Rgds
Rajani Kanth

haneefm [Syncfusion]
Replied On June 28, 2007 05:59 PM

Hi Rajani,

To change the sort direction in a column header, You need to handle the TableControlDrawCell and draw the sort triangle direction using the GridPaintTriangle.Paint() method.And also you need to turn off the default sort icon drawing by changing the ColumnHeader.Celltype to "Header". Please refer to the following code snippet demonstrates the technique to change sort direction.

this.gridGroupingControl1.TableDescriptor.Appearance.ColumnHeaderCell.CellType = "Header";

void gridGroupingControl1_TableControlDrawCell(object sender, GridTableControlDrawCellEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if (style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell)
{
e.Inner.Cancel = true;
e.Inner.Renderer.Draw(e.Inner.Graphics, e.Inner.Bounds, e.Inner.RowIndex, e.Inner.ColIndex, e.Inner.Style);
if (style.Tag != null)
{
ListSortDirection listSortDirection = (ListSortDirection)e.Inner.Style.Tag;
Rectangle rect = new Rectangle(e.Inner.Bounds.X + e.Inner.Bounds.Width / 3, e.Inner.Bounds.Y, e.Inner.Bounds.Width, e.Inner.Bounds.Height);// e.Bounds;
int i2 = Math.Max(0, (rect.Height - 4) / 2);
rect.Inflate(-i2, -i2);

Pen pen1 = new Pen(SystemColors.WindowFrame);
GridTriangleDirection triangleDirection = listSortDirection == ListSortDirection.Ascending ? GridTriangleDirection.Down : GridTriangleDirection.Up;
GridPaintTriangle.Paint(e.Inner.Graphics, rect, triangleDirection, Brushes.Black, pen1, true);
pen1.Dispose();
}
}
}

Best regards,
Haneef

Badri Rajani Kanth
Replied On June 29, 2007 04:45 AM

Hi Haneef,

Now I see two arrows, as old arrow is not yet removed.

These are my grid settings. Can you plz see if some thing is wrong?

this.gridGroupingControl1.BackColor = System.Drawing.SystemColors.Window;
this.gridGroupingControl1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.gridGroupingControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridGroupingControl1.Location = new System.Drawing.Point(0, 0);
this.gridGroupingControl1.Name = "gridGroupingControl1";
this.gridGroupingControl1.Size = new System.Drawing.Size(718, 98);
this.gridGroupingControl1.TabIndex = 0;
this.gridGroupingControl1.VersionInfo = "3.201.1.0";

gridGroupingControl1.TableOptions.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.None;
gridGroupingControl1.TableOptions.ListBoxSelectionCurrentCellOptions =
Syncfusion.Windows.Forms.Grid.Grouping.GridListBoxSelectionCurrentCellOptions.None;
gridGroupingControl1.TableOptions.ListBoxSelectionMode = System.Windows.Forms.SelectionMode.One;
gridGroupingControl1.TableModel.Options.ShowCurrentCellBorderBehavior =
GridShowCurrentCellBorder.HideAlways;
gridGroupingControl1.TableModel.Options.SelectCellsMouseButtonsMask =
System.Windows.Forms.MouseButtons.Left | System.Windows.Forms.MouseButtons.Right;
gridGroupingControl1.TableControl.HScrollBehavior = GridScrollbarMode.Disabled;
gridGroupingControl1.TableOptions.IndentWidth = GRID_INDENT_WIDTH;
gridGroupingControl1.TableOptions.ShowRowHeader = false;
gridGroupingControl1.TableOptions.CaptionRowHeight = GRID_CAPTION_ROW_HEIGHT;


//To change the sort direction in a column header
gridGroupingControl1.TableDescriptor.Appearance.ColumnHeaderCell.CellType = "Header";
gridGroupingControl1.TableControlDrawCell -= new GridTableControlDrawCellEventHandler(gridGroupingControl1_TableControlDrawCell);
gridGroupingControl1.TableControlDrawCell += new GridTableControlDrawCellEventHandler(gridGroupingControl1_TableControlDrawCell);

//Make sure columns will not be resiged to zero width
gridGroupingControl1.TableControlResizingColumns -= new GridTableControlResizingColumnsEventHandler(gridGroupingControl1_TableControlResizingColumns);
gridGroupingControl1.TableControlResizingColumns += new GridTableControlResizingColumnsEventHandler(gridGroupingControl1_TableControlResizingColumns);


//subscribe event to remove the dotted border around group drop area DragColumnHeaderText
gridGroupingControl1.GridGroupDropArea.PrepareViewStyleInfo -=
new GridPrepareViewStyleInfoEventHandler(GridGroupDropArea_PrepareViewStyleInfo);
gridGroupingControl1.GridGroupDropArea.PrepareViewStyleInfo +=
new GridPrepareViewStyleInfoEventHandler(GridGroupDropArea_PrepareViewStyleInfo);

gridGroupingControl1.TopLevelGroupOptions.ShowCaption = false;
gridGroupingControl1.ChildGroupOptions.ShowSummaries = false;
gridGroupingControl1.ChildGroupOptions.ShowAddNewRecordBeforeDetails = false;
gridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false;


gridGroupingControl1.TableDescriptor.AllowEdit = false;
gridGroupingControl1.TableDescriptor.AllowNew = false;
gridGroupingControl1.TableDescriptor.AllowRemove = false;
gridGroupingControl1.TopLevelGroupOptions.ShowCaption = false;
gridGroupingControl1.TableOptions.ShowRowHeader = false;

gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.None;
gridGroupingControl1.TableModel.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;

gridGroupingControl1.TableOptions.ShowRowHeader = false;
gridGroupingControl1.TableOptions.ListBoxSelectionCurrentCellOptions = Syncfusion.Windows.Forms.Grid.Grouping.GridListBoxSelectionCurrentCellOptions.None;
gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;


//Borders
gridGroupingControl1.Appearance.AnyRecordFieldCell.Borders.Bottom = new Syncfusion.Windows.Forms.Grid.GridBorder(Syncfusion.Windows.Forms.Grid.GridBorderStyle.Solid, System.Drawing.SystemColors.Control);
//gridGroupingControl1.Appearance.AnyCell.Borders.Top = new Syncfusion.Windows.Forms.Grid.GridBorder(Syncfusion.Windows.Forms.Grid.GridBorderStyle.None);
gridGroupingControl1.Appearance.AnyRecordFieldCell.Borders.Left = new Syncfusion.Windows.Forms.Grid.GridBorder(Syncfusion.Windows.Forms.Grid.GridBorderStyle.Solid, System.Drawing.SystemColors.Control);
gridGroupingControl1.Appearance.AnyRecordFieldCell.Borders.Right = new Syncfusion.Windows.Forms.Grid.GridBorder(Syncfusion.Windows.Forms.Grid.GridBorderStyle.Solid, System.Drawing.SystemColors.Control);

gridGroupingControl1.TableControlKeyDown -= new GridTableControlKeyEventHandler(gridGroupingControl1_TableControlKeyDown);
gridGroupingControl1.TableControlKeyDown += new GridTableControlKeyEventHandler(gridGroupingControl1_TableControlKeyDown);

gridGroupingControl1.TableControlKeyUp -= new GridTableControlKeyEventHandler(gridGroupingControl1_TableControlKeyUp);
gridGroupingControl1.TableControlKeyUp += new GridTableControlKeyEventHandler(gridGroupingControl1_TableControlKeyUp);
//gridGroupingControl1.CurrentRecordContextChange +=new Syncfusion.Grouping.CurrentRecordContextChangeEventHandler(gridGroupingControl1_CurrentRecordContextChange);
gridGroupingControl1.TableModel.Options.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;
gridGroupingControl1.TableModel.ClipboardCanCopy += new GridCutPasteEventHandler(TableModel_ClipboardCanCopy);
gridGroupingControl1.Appearance.AnyRecordFieldCell.CellType = "Static";
gridGroupingControl1.TableDescriptor.Appearance.AnyRecordFieldCell.CellType = "Static";

gridGroupingControl1.GridGroupDropArea.BackColor = SystemColors.ActiveCaption;

// OutlookKeysForGGControl outlook=new OutlookKeysForGGControl(gridGroupingControl1);

if(applyCustomFont)
{
GridFontInfo mGridFont = new GridFontInfo();
mGridFont.Facename = mStandardFont.FontFamily.Name;
mGridFont.Size = mStandardFont.Size;

//For Header Text in a grid.
//gridGroupingControl1.Appearance.AnyHeaderCell.ResetFont();
//gridGroupingControl1.Appearance.AnyHeaderCell.Font = mGridFont;


//For Group Font
gridGroupingControl1.GridGroupDropArea.Font = mStandardFont;

//For Grid Text
gridGroupingControl1.Font = mStandardFont;
}
else
{
gridGroupingControl1.Font = DEFAULT_STANDARD_FONT;
}

//auto preview row
gridGroupingControl1.Appearance.AnyPreviewCell.Font.Italic = false;
gridGroupingControl1.Appearance.AnyPreviewCell.TextColor = Color.Blue;

Thanks & Rgds
Rajani Kanth

haneefm [Syncfusion]
Replied On June 29, 2007 07:22 PM

Hi Rajani,

You can turn off the default sort direction drawing by using the ColumnHeaderCell.CellType property in a bottom of the form's load event. Below is a code snippet

[c#]
Bottom line of the form's load event
gridGroupingControl1.TableDescriptor.Appearance.ColumnHeaderCell.CellType = "Header";

Best Regards,
Haneef

CONFIRMATION

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.

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.

;