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

Marking / highlighting groupable colums

I'd like to mark or highlight colums that are groupable (AllowGroupByColumn = true). I thought about a foreach loop to process all the colum headers like:
foreach()
{if (AllowGroupByColumn == true)
HeaderText = "MyText" =+ " *";
}

or soemthing like that.

Do you have any ideo how to figure that out?

4 Replies

HA haneefm Syncfusion Team June 5, 2007 09:21 PM UTC

Hi Christoph,

You can handle the QueryCellStyleInfo event to detect whether the grid can be grouped by this column when the user drags the column over GroupDropArea and set the style property of the column. Below is a code snippet

private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if( e.TableCellIdentity.Column != null
&& e.TableCellIdentity.Column.AllowGroupByColumn )
{
if( e.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell )
{
e.Style.Themed = false;
e.Style.BackColor = Color.Blue;
}
else
e.Style.BackColor = Color.SkyBlue;
}
}

Best regards,
Haneef


CG Christoph Gasser June 6, 2007 02:27 PM UTC

Thank you. It's nearly working ;-) I've added the following code:

private void CustomizedGridGrouping_FormatColumHeader(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.Column != null && e.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell && e.TableCellIdentity.Column.AllowGroupByColumn)
{
e.TableCellIdentity.Column.HeaderText += "*";
}
}

I'm calling this in the init part of the form (once).

this.ggcPurchaseList.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(CustomizedGridGrouping_FormatColumHeader);

The result is, that I don't get a single * after each ColumnHeader name but instead the application is producing constantly * like and when I debugg I can see that the function from above is working like it would be in an endless loop.

Any idea how to run this code only once?


HA haneefm Syncfusion Team June 6, 2007 07:06 PM UTC

Hi Christoph,

You can prevent the repeated occurrence of '*' using the string.IndexOf method in QueryCellStyleInfo event. Below is a code snippet

private void CustomizedGridGrouping_FormatColumHeader(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.Column != null && e.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell && e.TableCellIdentity.Column.AllowGroupByColumn)
{
if( e.TableCellIdentity.Column.HeaderText.Indexof("*") > -1 )
e.TableCellIdentity.Column.HeaderText += "*";
}
}

Best regards,
Haneef


CG Christoph Gasser June 6, 2007 07:26 PM UTC

Thank you for your great support. Just in case anyone needs it:

Problem: Mark all groupable (=AllowGroupByColumn) columns with a special character (in my case it is a *) automatically so that a user knows which column header he is able to drag to the GroupDropArea.

Solution:
private void FormatColumHeader(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.Column != null && e.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell && e.TableCellIdentity.Column.AllowGroupByColumn)
{
if (!e.TableCellIdentity.Column.HeaderText.EndsWith("*"))
e.TableCellIdentity.Column.HeaderText += "*";
}
}

This function is called in the init part of the form like that:
this.myGridGroupControl.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(FormatColumHeader);

Loader.
Live Chat Icon For mobile
Up arrow icon