How do I get the column name when on a summary row or caption row?

ow do I get the column name when on a summary row or caption row?

How do I get the column name of the current cell when the current cell is a summary row of a child table?

1 Reply

AD Administrator Syncfusion Team September 19, 2006 05:24 AM UTC

Hi James,

You can use code like:

GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(cc.RowIndex, cc.ColIndex);

switch(style.TableCellIdentity.DisplayElement.Kind )
{
case DisplayElementKind.Summary:
GridSummaryRow row = style.TableCellIdentity.DisplayElement as GridSummaryRow;
if( style.TableCellIdentity.SummaryColumn != null)
{
Console.WriteLine(style.TableCellIdentity.SummaryColumn.Name);
}
else /* Empty SummaryColumn*/
{
int index = row.ParentTableDescriptor.ColIndexToField(cc.ColIndex);
Console.WriteLine(row.ParentTableDescriptor.Columns[index].Name );
}
break;
case DisplayElementKind.Caption:
GridCaptionRow row1 = style.TableCellIdentity.DisplayElement as GridCaptionRow;
int index1 = row1.ParentTableDescriptor.ColIndexToField(cc.ColIndex);
Console.WriteLine(row1.ParentTableDescriptor.Columns[index1].Name );
break;
}

to get the information you wanted.

Thanks,
Haneef

Loader.
Up arrow icon