原創(chuàng)|其它|編輯:郝浩|2012-09-21 17:07:34.000|閱讀 576 次
概述:下面的示例演示了在運(yùn)行的時(shí)候如何創(chuàng)建一個(gè)新的空白報(bào)表(XtraReport類的一個(gè)實(shí)例),創(chuàng)建數(shù)據(jù)對(duì)象,并綁定MDB文件(通過XtraReportBase.DataSource, XtraReportBase.DataAdapte和traReportBase.DataMember 屬性),然后用包含XRLabel(顯示數(shù)據(jù)來自該文件)的DetailBand填充報(bào)表。附代碼。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
下面的示例演示了DevExpress報(bào)表控件XtraReports在運(yùn)行的時(shí)候如何創(chuàng)建一個(gè)新的空白報(bào)表(XtraReport類的一個(gè)實(shí)例),創(chuàng)建數(shù)據(jù)對(duì)象,并綁定MDB文件(通過XtraReportBase.DataSource、XtraReportBase.DataAdapte和traReportBase.DataMember 屬性),然后用包含XRLabel(顯示數(shù)據(jù)來自該文件)的DetailBand填充報(bào)表。
C#
using System;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
// ...
private void button1_Click(object sender, EventArgs e) {
// Create an empty report.
XtraReport report = new XtraReport();
// Create data objects.
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Categories",
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\nwind.mdb");
DataSet ds = new DataSet();
adapter.FillSchema(ds, SchemaType.Source);
// Bind the report to data.
report.DataSource = ds;
report.DataAdapter = adapter;
report.DataMember = "Table";
// Add a detail band to the report.
DetailBand detailBand = new DetailBand();
detailBand.Height = 50;
report.Bands.Add(detailBand);
// Add a label to the detail band.
XRLabel label = new XRLabel();
label.DataBindings.Add("Text", null, "CategoryName");
detailBand.Controls.Add(label);
// Show the report's print preview.
report.ShowPreview();
}
VB
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows.Forms
Imports DevExpress.XtraReports.UI
' ...
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles button1.Click
' Create an empty report.
Dim report As New XtraReport()
' Create data objects.
Dim adapter As New OleDbDataAdapter("SELECT * FROM Categories", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\nwind.mdb")
Dim ds As New DataSet()
adapter.FillSchema(ds, SchemaType.Source)
' Bind the report to data.
report.DataSource = ds
report.DataAdapter = adapter
report.DataMember = "Table"
' Add a detail band to the report.
Dim detailBand As New DetailBand()
detailBand.Height = 50
report.Bands.Add(detailBand)
' Add a label to the detail band.
Dim label As New XRLabel()
label.DataBindings.Add("Text", Nothing, "CategoryName")
detailBand.Controls.Add(label)
' Show the report's print preview.
report.ShowPreview()
End Sub
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)