Home Forums WinForms controls Xceed Grid for WinForms Possible error initializing SummaryCell in 3.9 Reply To: Possible error initializing SummaryCell in 3.9

Xceed Support
Member
Post count: 5658

Hi Ron,

The folowing is taken from our sample “StarterGrid” and is the right way to declare and initialize a SummaryRow:

// The folowing line creates a SummaryRow which will be used

// to display the average unit price (Unit Price) for the data rows

// contained in each group.

SummaryRow averageUnitPriceSumRow = new SummaryRow();

SummaryRow defaultAverageUnitPrice = new SummaryRow();

// Display the result of the average of the “UnitPrice” column through the SummaryRow.

averageUnitPriceSumRow.TextFormat =

“Average Unit Price: %AVG:UnitPrice format=c%”;

defaultAverageUnitPrice.TextFormat =

“Average Unit Price: %AVG:UnitPrice format=c%”;

// The following line accesses the first group template used in the grid.

// It adds the previously created SummaryRow to this group’s footer rows. Note: the

// SummaryRow could have been added to the group’s footer rows by directly using the

// “group” variable created above (group.FooterRows.Add…).

starterGrid.GroupTemplates[ 0 ].FooterRows.Add( averageUnitPriceSumRow );

// Add a running sum for the “UnitsInStock” column. This needs to be done after the

// SummaryRow has been added to the grid’s GroupTemplates.

SummaryCell cell = ( SummaryCell )averageUnitPriceSumRow.Cells[ “UnitsInStock” ];

cell.StatFunction =

StatFunction.Sum;

cell.RunningStatGroupLevel = 0;

cell.TitleFormat =

“Total units in stock so far.”;

// If there is not enough room to display the cell’s title to the right, don’t display it.

cell.TitlePosition =

TitlePosition.AlwaysRight;

defaultGroup.FooterRows.Add( defaultAverageUnitPrice );

Imported from legacy forums. Posted by Alain [Xceed] (had 188 views)