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

How to find the corresponding group item when user click on a summary line?

Thread ID:

Created:

Updated:

Platform:

Replies:

59906 Apr 24,2007 03:48 PM UTC Apr 25,2007 01:31 PM UTC Windows Forms 5
loading
Tags: Grouping
JP
Asked On April 24, 2007 03:48 PM UTC

What is the right way to find the group information when a user clicks on a cell in a summary line? Also, how can I find the column name of the cell the user clicked?

Thanks

haneefm [Syncfusion]
Replied On April 24, 2007 06:50 PM UTC

Hi JP,

If you want to get a column name and it group details when clicked on the cell in a grid, you can use the below code:

private void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex,e.Inner.ColIndex) ;
if( style != null )
{
Console.WriteLine( "GroupDetails " + style.TableCellIdentity.DisplayElement.ParentGroup);
if( style.TableCellIdentity.Column != null )
Console.WriteLine("Column Name" + style.TableCellIdentity.Column.Name);
else if( style.TableCellIdentity.SummaryColumn != null)
Console.WriteLine("Column Name" + style.TableCellIdentity.SummaryColumn.Name);
}
}

Best regards,
Haneef

JP
Replied On April 24, 2007 08:10 PM UTC

Thanks Haneef,

I think this is exactly what I need. I have two further questions:
1. Givng a group, how to find the grouping criteria? For example, if I have 3 grouping columns, how can I find the values of those three columns for the group?
2. How to align a cell? I ask this because the summary cell has left alignment while the correspoing column has righ alignment because they are numbers. I tried the following code which did not work:
sdBuy.Appearance.SummaryFieldCell.TextAlign = GridTextAlign.Right;

sdBuy here is a GridSummaryColumnDescriptor

Thanks for your time.

>Hi JP,

If you want to get a column name and it group details when clicked on the cell in a grid, you can use the below code:

private void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex,e.Inner.ColIndex) ;
if( style != null )
{
Console.WriteLine( "GroupDetails " + style.TableCellIdentity.DisplayElement.ParentGroup);
if( style.TableCellIdentity.Column != null )
Console.WriteLine("Column Name" + style.TableCellIdentity.Column.Name);
else if( style.TableCellIdentity.SummaryColumn != null)
Console.WriteLine("Column Name" + style.TableCellIdentity.SummaryColumn.Name);
}
}

Best regards,
Haneef

JP
Replied On April 24, 2007 08:57 PM UTC

Found the answer for my second question. Set
HorizontalAlignment instead of TextAlign.

Still need help for the first question. Thanks.

>Thanks Haneef,

I think this is exactly what I need. I have two further questions:
1. Givng a group, how to find the grouping criteria? For example, if I have 3 grouping columns, how can I find the values of those three columns for the group?
2. How to align a cell? I ask this because the summary cell has left alignment while the correspoing column has righ alignment because they are numbers. I tried the following code which did not work:
sdBuy.Appearance.SummaryFieldCell.TextAlign = GridTextAlign.Right;

sdBuy here is a GridSummaryColumnDescriptor

Thanks for your time.

haneefm [Syncfusion]
Replied On April 24, 2007 10:31 PM UTC

Hi JP,

If you want to get the group category then use the ParentGroup.Category to access it. Here is a code snippet.

style.TableCellIdentity.DisplayElement.ParentGroup.Category

If you want to get record collection from the group then call the ParentGroup.Records property. And then you can use the GetValue/SetValue method to get value from the GridRecord. Here is a code snippet.

foreach(Record rec in style.TableCellIdentity.DisplayElement.ParentGroup.Records)
{
Consle.WriteLine( r.Info); //r.GetValue("ColumnName");
}

Best regards,
Haneef

JP
Replied On April 25, 2007 01:31 PM UTC

Thanks. That's exactly what I was looking for.

>Hi JP,

If you want to get the group category then use the ParentGroup.Category to access it. Here is a code snippet.

style.TableCellIdentity.DisplayElement.ParentGroup.Category

If you want to get record collection from the group then call the ParentGroup.Records property. And then you can use the GetValue/SetValue method to get value from the GridRecord. Here is a code snippet.

foreach(Record rec in style.TableCellIdentity.DisplayElement.ParentGroup.Records)
{
Consle.WriteLine( r.Info); //r.GetValue("ColumnName");
}

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.

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

;