摘錄的WinForm Control 開發5,WinForm 開發:RDLCCustomAssemblyAccessFS,報表開發,之自訂報表,自訂初始化

來源:互聯網
上載者:User
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();

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.