Grouping is a common method for organizing data. After designing the basic layout, you may choose to segregate records by specific fields or criteria to make the report easier to read. Grouping data allows you to separate sets of records and display introductory and summary data for each group. The group break is determined by a grouping expression, which is typically based on one or more recordset fields but can be as complex as needed.
In FlexReport, grouping is achieved using FlexReport.Groups. For example, if you want to view a list of products based on suppliers who supply multiple products, you would group the list by Supplier. The following steps illustrate how to group the list of products by Supplier in the report:
C# |
Copy Code
|
---|---|
Group grp; grp = flexReport.Groups.Add("Supplier", "Supplier", SortEnum.Ascending); C1.Win.FlexReport.Section s; s = grp.SectionHeader; s.Height = 1000; s.Visible = true; TextField f = new TextField(); f.Name = "Supplier"; f.Text.Expression = "Supplier"; f.Left = 0; f.Top = 0; f.Width = flexReport.Layout.Width; f.Height = 500; f.Align = FieldAlignEnum.LeftMiddle; f.Font.Bold = true; f.Font.Size = 12; f.Border = new C1.Win.Document.Border(2, Color.FromArgb(0, 0, 0), C1.Win.Document.DashStyle.Solid); f.BackColor = Color.FromArgb(150, 150, 220); f.MarginLeft = 100; s.Fields.Add(f); flexReport.Render(); |