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.
Syncfusion Feedback

Marking / highlighting groupable colums

Thread ID:

Created:

Updated:

Platform:

Replies:

61971 Jun 5,2007 02:54 PM UTC Jun 6,2007 07:26 PM UTC Windows Forms 4
loading
Tags: GridControl
Christoph Gasser
Asked On June 5, 2007 02:54 PM UTC

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?

haneefm [Syncfusion]
Replied On 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

Christoph Gasser
Replied On 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?

haneefm [Syncfusion]
Replied On 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

Christoph Gasser
Replied On 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);

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.

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

;