• <menu id="w2i4a"></menu>
  • logo Stimulsoft Reports.WinForms教程-2019

    文檔首頁(yè)>>Stimulsoft Reports.WinForms教程-2019>>【Stimulsoft Reports.WinForms教程】在運(yùn)行時(shí)創(chuàng)建一個(gè)新報(bào)表

    【Stimulsoft Reports.WinForms教程】在運(yùn)行時(shí)創(chuàng)建一個(gè)新報(bào)表


    【下載Stimulsoft Reports.Ultimate最新版本】

    此示例顯示如何在運(yùn)行時(shí)創(chuàng)建簡(jiǎn)單報(bào)表,讓我們創(chuàng)建包含標(biāo)題,數(shù)據(jù),總計(jì)的報(bào)表,并在查看器中顯示它。首先,創(chuàng)建一個(gè)新報(bào)表并將數(shù)據(jù)源添加到dictionary中:

    private void button1_Click(object sender, System.EventArgs e)
    {
        StiReport report = new StiReport();
     
        //Add data to datastore
        report.RegData(dataSet1);
     
        //Fill dictionary
        report.Dictionary.Synchronize();
     
        StiPage page = report.Pages[0];
    ...

    添加Header Band與Text Boxes,并為其指定data titles:

    ...
        //Create HeaderBand
        StiHeaderBand headerBand = new StiHeaderBand();
        headerBand.Height = 0.5;
        headerBand.Name = "HeaderBand";
        page.Components.Add(headerBand);
     
        //Create text on header
        StiText 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);
    ...

    接下來(lái),添加帶有Text Boxes的Data Band,其中包含對(duì)數(shù)據(jù)字段的引用:

    ...
        //Create Databand
        StiDataBand dataBand = new StiDataBand();
        dataBand.DataSourceName = "Customers";
        dataBand.Height = 0.5;
        dataBand.Name = "DataBand";
        page.Components.Add(dataBand);
     
        //Create text
        StiText dataText = new StiText(new RectangleD(0, 0, 5, 0.5));
        dataText.Text = "{Line}.{Customers.CompanyName}";
        dataText.Name = "DataText";
        dataBand.Components.Add(dataText);
    ...

    下一步,添加帶有Text Boxes的Footer Band,其中包含數(shù)據(jù)總計(jì)的功能:

    ...
        //Create FooterBand
        StiFooterBand footerBand = new StiFooterBand();
        footerBand.Height = 0.5;
        footerBand.Name = "FooterBand";
        page.Components.Add(footerBand);
     
        //Create text on footer
        StiText 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);
    ...

    最后,在查看器中顯示報(bào)表:

    ...
        report.Show();
    }

    示例代碼的結(jié)果如下圖所示:

    Stimulsoft

    下載示例

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();