12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?xml version="1.0" encoding="utf-8"?>
- <Report ScriptLanguage="CSharp" ReportInfo.Description="Demonstrates how to create a drill-down group report. The report uses a script to hide or show a group: - add CheckBox object on a group header and set up its Hyperlink: set Kind to "Custom" and Value to group's name; - create a Click event handler that will be executed when you click the checkbox; - create a BeforePrint event handler of a group header. In the handler, check whether current group is visible or not. See the script's code for more details. Learn how to build this report on the Fast Reports Academy channel http://fast.report/bab94" ReportInfo.Created="01/17/2008 04:31:41" ReportInfo.Modified="04/07/2023 11:27:17" ReportInfo.CreatorVersion="1.0.0.0">
- <ScriptText>using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Data;
- using FastReport;
- using FastReport.Data;
- using FastReport.Dialog;
- using FastReport.Barcode;
- using FastReport.Table;
- using FastReport.Utils;
- namespace FastReport
- {
- public class ReportScript
- {
- // list of visible groups
- private List<string> expandedGroups = new List<string>();
-
- private void GroupHeader1_BeforePrint(object sender, EventArgs e)
- {
- // check if current group is visible
- string groupName = ((String)Report.GetColumnValue("Products.ProductName")).Substring(0, 1);
- bool groupVisible = expandedGroups.Contains(groupName);
-
- // toggle objects visibility
- Data1.Visible = groupVisible;
- GroupFooter1.Visible = groupVisible;
-
- // toggle indicator
- CheckBox1.Checked = !groupVisible;
- }
- private void CheckBox1_Click(object sender, EventArgs e)
- {
- // get a group name
- string groupName = (sender as CheckBoxObject).Hyperlink.Value;
-
- // toggle group
- if (expandedGroups.Contains(groupName))
- expandedGroups.Remove(groupName);
- else
- expandedGroups.Add(groupName);
-
- // refresh the report
- Report.Refresh();
- }
- }
- }
- </ScriptText>
- <Styles>
- <Style Name="EvenRows" Fill.Color="WhiteSmoke" Font="Arial, 10pt" ApplyBorder="false" ApplyTextFill="false" ApplyFont="false"/>
- </Styles>
- <Dictionary>
- <TableDataSource Name="Products" ReferenceName="NorthWind.Products" DataType="System.Int32" Enabled="true">
- <Column Name="ProductID" DataType="System.Int32"/>
- <Column Name="ProductName" DataType="System.String"/>
- <Column Name="SupplierID" DataType="System.Int32"/>
- <Column Name="CategoryID" DataType="System.Int32"/>
- <Column Name="QuantityPerUnit" DataType="System.String"/>
- <Column Name="UnitPrice" DataType="System.Decimal"/>
- <Column Name="UnitsInStock" DataType="System.Int16"/>
- <Column Name="UnitsOnOrder" DataType="System.Int16"/>
- <Column Name="ReorderLevel" DataType="System.Int16"/>
- <Column Name="Discontinued" DataType="System.Boolean" BindableControl="CheckBox"/>
- <Column Name="EAN13" DataType="System.String"/>
- </TableDataSource>
- <Total Name="TotalProducts" TotalType="Count" Evaluator="Data1" PrintOn="GroupFooter1"/>
- </Dictionary>
- <ReportPage Name="Page1" Watermark.Font="Arial, 60pt">
- <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="47.25" CanGrow="true">
- <TextObject Name="Text1" Width="718.2" Height="37.8" Text="ALPHABETICAL PRODUCT LIST" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
- </ReportTitleBand>
- <GroupHeaderBand Name="GroupHeader1" Top="49.25" Width="718.2" Height="37.8" BeforePrintEvent="GroupHeader1_BeforePrint" KeepWithData="true" Condition="[Products.ProductName].Substring(0,1)" SortOrder="None">
- <TextObject Name="Text7" Left="37.8" Top="9.45" Width="359.1" Height="28.35" Border.Color="LightSkyBlue" Fill.Color="110, 145, 190" Hyperlink.Kind="Custom" Hyperlink.Expression="[Products.ProductName].Substring(0,1)" Text="[[Products.ProductName].Substring(0,1)]" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold" TextFill.Color="White"/>
- <CheckBoxObject Name="CheckBox1" Left="9.45" Top="14.45" Width="18.9" Height="18.9" Border.Lines="All" Border.Color="DarkGray" Cursor="Hand" Hyperlink.Kind="Custom" Hyperlink.Expression="[Products.ProductName].Substring(0,1)" ClickEvent="CheckBox1_Click" CheckedSymbol="Plus" UncheckedSymbol="Minus"/>
- <DataBand Name="Data1" Top="89.05" Width="718.2" Height="18.9" Visible="false" DataSource="Products">
- <TextObject Name="Text2" Left="37.8" Width="264.6" Height="18.9" Border.Lines="Left" Border.Color="Gainsboro" EvenStyle="EvenRows" Text="[Products.ProductName]" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TextObject Name="Text4" Left="302.4" Width="94.5" Height="18.9" Border.Lines="Right" Border.Color="Gainsboro" EvenStyle="EvenRows" Text="[Products.UnitPrice]" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <Sort>
- <Sort Expression="[Products.ProductName]"/>
- </Sort>
- </DataBand>
- <GroupFooterBand Name="GroupFooter1" Top="109.95" Width="718.2" Height="18.9" Visible="false" KeepWithData="true">
- <TextObject Name="Text8" Left="37.8" Width="359.1" Height="18.9" Border.Lines="Left, Right, Bottom" Border.Color="Gainsboro" Text="Total products: [TotalProducts]" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
- </GroupFooterBand>
- </GroupHeaderBand>
- <PageFooterBand Name="PageFooter1" Top="130.85" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke">
- <TextObject Name="Text9" Left="623.7" Width="94.5" Height="28.35" Text="[PageN]" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TextObject Name="Text12" Left="9.45" Width="217.35" Height="28.35" Cursor="Hand" Hyperlink.Value="https://www.fast-report.com/en/product/fast-report-net/" Text="Generated by FastReport" VertAlign="Center" Font="Segoe UI, 9pt, style=Underline" TextFill.Color="Blue"/>
- </PageFooterBand>
- </ReportPage>
- </Report>
|