此示例显示如何在运行系统中创建一个简单的 告。让我们创建包含标题、数据、总计的 告并将其显示在查看器中。
此示例显示如何在运行系统中创建一个简单的 告。让我们创建包含标题、数据、总计的 告并将其显示在查看器中。首先,创建一个新 告并将数据源添加到字典中:
private void button1_Click(object sender, System.EventArgs e){StiReport report = new StiReport();// Add data to datastorereport.RegData(dataSet1);// Fill dictionaryreport.Dictionary.Synchronize();StiPage page = report.Pages[0];...
添加带有文本框的标题带并为其分配数据标题:
...// Create HeaderBandStiHeaderBand headerBand = new StiHeaderBand();headerBand.Height = 0.5;headerBand.Name = "HeaderBand";page.Components.Add(headerBand);// Create text on headerStiText headerText = new StiText(new RectangleD(0, 0, 5, 0.5));headerText.Text = "CompanyName";headerText.HorAlignment = StiTextHorAlignment.Center;headerText.Name = "HeaderText";headerText.Brush = new StiSolidBrush(Color.LightGreen);headerBand.Components.Add(headerText);...
接下来,添加一个带有文本框的数据带,其中包含对数据字段的引用:
...// Create DatabandStiDataBand dataBand = new StiDataBand();dataBand.DataSourceName = "Customers";dataBand.Height = 0.5;dataBand.Name = "DataBand";page.Components.Add(dataBand);// Create textStiText dataText = new StiText(new RectangleD(0, 0, 5, 0.5));dataText.Text = "{Line}.{Customers.CompanyName}";dataText.Name = "DataText";dataBand.Components.Add(dataText);...
接下来,添加一个带有文本框的数据带,其中包含对数据字段的引用:
...// Create DatabandStiDataBand dataBand = new StiDataBand();dataBand.DataSourceName = "Customers";dataBand.Height = 0.5;dataBand.Name = "DataBand";page.Components.Add(dataBand);// Create textStiText dataText = new StiText(new RectangleD(0, 0, 5, 0.5));dataText.Text = "{Line}.{Customers.CompanyName}";dataText.Name = "DataText";dataBand.Components.Add(dataText);...
接下来,添加一个带有文本框的页脚带,其中包含数据总计的函数:
...// Create FooterBandStiFooterBand footerBand = new StiFooterBand();footerBand.Height = 0.5;footerBand.Name = "FooterBand";page.Components.Add(footerBand);// Create text on footerStiText footerText = new StiText(new RectangleD(0, 0, 5, 0.5));footerText.Text = "Count - {Count()}";footerText.HorAlignment = StiTextHorAlignment.Right;footerText.Name = "FooterText";footerText.Brush = new StiSolidBrush(Color.LightGreen);footerBand.Components.Add(footerText);...
最后,在查看器中显示一个 告:
...report.Show();}
在下面的屏幕截图中,您可以看到示例代码的结果:

Aspose、E-iceblue、FastReport、Stimulsoft等文档/ 表图表类开发工具享超低折扣,如有需要可直接联系在线客服。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!