Row Datasource.frx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Report ScriptLanguage="CSharp" ReportInfo.Description="Demonstrates how to print multiple Table rows with a script. To do this:&#13;&#10;- select the Table object;&#13;&#10;- go to the &quot;Properties&quot; window and click the &quot;Events&quot; button to view a list of available events;&#13;&#10;- doubleclick the &quot;ManualBuild&quot; event;&#13;&#10;- you will see an empty event handler. You need to print rows using the &quot;TableObject.PrintRow&quot; method; in each row, you must also print all the columns (using &quot;PrintColumns&quot; method). See the script's code for more details.&#13;&#10;When you run a report, the Table will repeat a row and fill it with data." ReportInfo.Created="01/17/2008 20:40:24" ReportInfo.Modified="04/07/2023 18:06:50" ReportInfo.CreatorVersion="1.0.0.0">
  3. <ScriptText>using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Windows.Forms;
  8. using System.Drawing;
  9. using System.Data;
  10. using FastReport;
  11. using FastReport.Data;
  12. using FastReport.Dialog;
  13. using FastReport.Barcode;
  14. using FastReport.Table;
  15. using FastReport.Utils;
  16. namespace FastReport
  17. {
  18. public class ReportScript
  19. {
  20. private void Table1_ManualBuild(object sender, EventArgs e)
  21. {
  22. // get the data source by its name
  23. DataSourceBase rowData = Report.GetDataSource(&quot;Products&quot;);
  24. // init the data source
  25. rowData.Init();
  26. // print the first table row - it is a header
  27. Table1.PrintRow(0);
  28. // each PrintRow call must be followed by either PrintColumn or PrintColumns call
  29. // to print cells on the row
  30. Table1.PrintColumns();
  31. // now enumerate the data source and print the table body
  32. while (rowData.HasMoreRows)
  33. {
  34. // print the table body
  35. Table1.PrintRow(1);
  36. Table1.PrintColumns();
  37. // go next data source row
  38. rowData.Next();
  39. }
  40. // print the last table row - it is a footer
  41. Table1.PrintRow(2);
  42. Table1.PrintColumns();
  43. }
  44. }
  45. }
  46. </ScriptText>
  47. <Dictionary>
  48. <TableDataSource Name="Products" ReferenceName="NorthWind.Products" DataType="System.Int32" Enabled="true">
  49. <Column Name="ProductID" DataType="System.Int32"/>
  50. <Column Name="ProductName" DataType="System.String"/>
  51. <Column Name="SupplierID" DataType="System.Int32"/>
  52. <Column Name="CategoryID" DataType="System.Int32"/>
  53. <Column Name="QuantityPerUnit" DataType="System.String"/>
  54. <Column Name="UnitPrice" DataType="System.Decimal"/>
  55. <Column Name="UnitsInStock" DataType="System.Int16"/>
  56. <Column Name="UnitsOnOrder" DataType="System.Int16"/>
  57. <Column Name="ReorderLevel" DataType="System.Int16"/>
  58. <Column Name="Discontinued" DataType="System.Boolean" BindableControl="CheckBox"/>
  59. <Column Name="EAN13" DataType="System.String"/>
  60. </TableDataSource>
  61. </Dictionary>
  62. <ReportPage Name="Page1" Watermark.Font="Arial, 60pt">
  63. <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8" CanGrow="true">
  64. <TextObject Name="Text2" Width="718.2" Height="37.8" Text="PRODUCTS LIST" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
  65. </ReportTitleBand>
  66. <DataBand Name="Data1" Top="39.8" Width="718.2" Height="153.67">
  67. <TableObject Name="Table1" Left="9.45" Top="11.92" Width="699.3" Height="56.7" ManualBuildEvent="Table1_ManualBuild">
  68. <TableColumn Name="Column1" Width="431.55"/>
  69. <TableColumn Name="Column2" Width="110.25"/>
  70. <TableColumn Name="Column3" Width="157.5"/>
  71. <TableRow Name="Row1">
  72. <TableCell Name="Cell1" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="Product name" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
  73. <TableCell Name="Cell2" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="Unit price" Padding="0, 0, 5, 0" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
  74. <TableCell Name="Cell3" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="Units in stock" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
  75. </TableRow>
  76. <TableRow Name="Row2">
  77. <TableCell Name="Cell6" Border.Lines="All" Border.Color="LightGray" Text="[Products.ProductName]" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 9pt"/>
  78. <TableCell Name="Cell7" Border.Lines="All" Border.Color="LightGray" Text="[Products.UnitPrice]" Padding="0, 0, 5, 0" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
  79. <TableCell Name="Cell8" Border.Lines="All" Border.Color="LightGray" Text="[Products.UnitsInStock]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt"/>
  80. </TableRow>
  81. <TableRow Name="Row3">
  82. <TableCell Name="Cell11" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" VertAlign="Center" Font="Segoe UI, 9pt"/>
  83. <TableCell Name="Cell12" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="Total:" Padding="0, 0, 5, 0" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
  84. <TableCell Name="Cell13" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="[Sum(Cell8)]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
  85. </TableRow>
  86. </TableObject>
  87. </DataBand>
  88. <PageFooterBand Name="PageFooter1" Top="195.47" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke">
  89. <TextObject Name="Text1" Left="614.25" Width="94.5" Height="28.35" Text="[PageN]" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
  90. <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"/>
  91. </PageFooterBand>
  92. </ReportPage>
  93. </Report>