zoukankan      html  css  js  c++  java
  • 摘录的WinForm Control 开发5,WinForm 开发:RDLCCustomAssemblyAccessFS,报表开发,之自定义报表,自定义初始化

    1,报表设计:平常的rdlc报表,在设计时,要添加数据库数据源。这样必须绑定数据库。我这里做到了报表与数据库分离。
    在窗体中自己给报表初始化,给报表赋值。

    2,报表设计:新建报表Report1.rdlc,添加数据源,选择对象,选择Mode层的Person
    如图:

     

     3,设置报表的数据源,设计报表的界面,拖入表格,然后把Person对象的字段赋值到表里边。然后设置报表数据源


    菜单:报表/数据源,如图:

     

     修改报表的数据源的名称为:myds


    设置报表中表格的数据源名称:myds

     4,加载报表,在窗体设计器里拖入ReportView

    选择刚才的报表,然后删除界面自动加入的“*DataSource”


    5,然后是自己写的初始化报表的代码:

    代码
                List<Person> listPerson = new List<Person>();
                Person per 
    = new Person("123"25);
                listPerson.Add(per);
                DataSet orderSet 
    = new DataSet();
                orderSet 
    = DataSetHelper.ToDataSet<Person>(listPerson as IList<Person>);
                
    this.reportViewer.LocalReport.DataSources.Clear();
                
    //this.reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("myds", DataSetHelper.ToDataTable(listPerson as IList<Person>)));
                this.reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("myds",listPerson.ToArray<Person>()));
                
    this.reportViewer.RefreshReport();
  • 相关阅读:
    洛谷 P1260 工程规划(差分约束)
    洛谷 P3660 [USACO17FEB]Why Did the Cow Cross the Road III G(树状数组)
    [模板]单调队列
    [模板]LIS(最长上升子序列)
    洛谷 P2899 [USACO08JAN]手机网络Cell Phone Network(树形动规)
    如何求数字n的因数个数及因数和
    [模板]tarjan缩点+拓扑排序
    itext生成pdf(附带页眉,页脚,页码)
    工作总结03
    工作总结02(海报上传模块)
  • 原文地址:https://www.cnblogs.com/csharponworking/p/1691996.html
Copyright © 2011-2022 走看看