Home Forums WinForms controls Xceed Grid for WinForms reapplying summaryrow Reply To: reapplying summaryrow

User (Old forums)
Member
Post count: 23064

First, I don’t see where you add the summary row to the group in the GridControl Begin/EndInit block.

i.e. : group.FooterRows.Add(sRow);

Second, I recommend that you try to add a group and then a Summary row to that group in the designer. This will create many lines of code. Analyze those line, and you will see how to properly set up a summary row within a group.

Basically, you need to add the summary row to the group, and set up the summary cell as needed. Here is code generated from the designer in C# :

private Xceed.Grid.SummaryRow summaryRow1;
private Xceed.Grid.SummaryCell cellsummaryRow1OrderID;
private Xceed.Grid.SummaryCell cellsummaryRow1ProductID;
private Xceed.Grid.SummaryCell cellsummaryRow1UnitPrice;
private Xceed.Grid.SummaryCell cellsummaryRow1Quantity;
private Xceed.Grid.SummaryCell cellsummaryRow1Discount;

this.summaryRow1 = new Xceed.Grid.SummaryRow();
this.cellsummaryRow1OrderID = new Xceed.Grid.SummaryCell();
this.cellsummaryRow1ProductID = new Xceed.Grid.SummaryCell();
this.cellsummaryRow1UnitPrice = new Xceed.Grid.SummaryCell();
this.cellsummaryRow1Quantity = new Xceed.Grid.SummaryCell();
this.cellsummaryRow1Discount = new Xceed.Grid.SummaryCell();

this.group1.FooterRows.Add(this.summaryRow1);
//only to show what is the group to which it is added
this.group1.GroupBy = “ProductID”;
this.group1.HeaderRows.Add(this.groupManagerRow1);

// summaryRow1
//
this.summaryRow1.Cells.Add(this.cellsummaryRow1OrderID);
this.summaryRow1.Cells.Add(this.cellsummaryRow1ProductID);
this.summaryRow1.Cells.Add(this.cellsummaryRow1UnitPrice);
this.summaryRow1.Cells.Add(this.cellsummaryRow1Quantity);
this.summaryRow1.Cells.Add(this.cellsummaryRow1Discount);
this.summaryRow1.TextFormat = “UnitPrice : %AVG: UnitPrice format=\”0.##\”%”;
this.summaryRow1.CellValueChanged += new System.EventHandler(this.summaryRow1_CellValueChanged);
//
// cellsummaryRow1OrderID
//
this.cellsummaryRow1OrderID.FormatSpecifier = “0.0000”;
this.cellsummaryRow1OrderID.ResultDataType = typeof(long);
this.cellsummaryRow1OrderID.Click += new System.EventHandler(this.cellsummaryRow1OrderID_Click);
this.cellsummaryRow1OrderID.Initialize(“OrderID”);
//
// cellsummaryRow1ProductID
//
this.cellsummaryRow1ProductID.ResultDataType = typeof(long);
this.cellsummaryRow1ProductID.Initialize(“ProductID”);
//
// cellsummaryRow1UnitPrice
//
this.cellsummaryRow1UnitPrice.TitleFormat = “52”;
this.cellsummaryRow1UnitPrice.TitlePosition = Xceed.Grid.TitlePosition.PreferablyRight;
this.cellsummaryRow1UnitPrice.Visible = true;
this.cellsummaryRow1UnitPrice.Initialize(“UnitPrice”);
//
// cellsummaryRow1Quantity
//
this.cellsummaryRow1Quantity.TitleFormat = “”;
this.cellsummaryRow1Quantity.Initialize(“Quantity”);
//
// cellsummaryRow1Discount
//
this.cellsummaryRow1Discount.FormatSpecifier = “0.##”;
this.cellsummaryRow1Discount.ResultDataType = typeof(System.Double);
this.cellsummaryRow1Discount.StatFunction = Xceed.Grid.StatFunction.Average;
this.cellsummaryRow1Discount.TitleFormat = “Discount”;
this.cellsummaryRow1Discount.Initialize(“Discount”);

Imported from legacy forums. Posted by André (had 4125 views)