2011-11-28 10:28 XtraReport动态绑定数据源 XtraReport report = new XtraReport(); string x = Application.StartupPath + @"\1.0\Report\InpFeeDetail.repx"; report.LoadLayout(x); report.DataSource = dtChargeDetail; report.FindControl("lblName", false).Text = register.Name; report.FindControl("lblTariffName", false).DataBindings.Add(new DevExpress.XtraReports.UI.XRBinding("Text", dtChargeDetail, "ChargeDetail.TariffName", "")); report.ShowPreview(); 需要先绑定DataSource
2011-11-28 10:28 XtraReport动态绑定数据源 XtraReport report = new XtraReport(); string x = Application.StartupPath + @"\1.0\Report\InpFeeDetail.repx"; report.LoadLayout(x); report.DataSource = dtChargeDetail; report.FindControl("lblName", false).Text = register.Name; report.FindControl("lblTariffName", false).DataBindings.Add(new DevExpress.XtraReports.UI.XRBinding("Text", dtChargeDetail, "ChargeDetail.TariffName", "")); report.ShowPreview(); 需要先绑定DataSource
问下 register.Name 这是什么意思?
using System;
using System.Data;
using System.Windows.Forms;namespace dxKB17175 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
} private void simpleButton2_Click(object sender, EventArgs e) {
XtraReport1 report = new XtraReport1(checkEdit1.Checked ? FillDatasetFromGrid() : nwindDataSet, gridView1);
report.ShowPreviewDialog();
}
private DataSet FillDatasetFromGrid() {
nwindDataSet ds = new nwindDataSet();
int rowHandle;
DataRow gridRow;
for(int i = 0; i < gridView1.RowCount; i++) {
rowHandle = gridView1.GetVisibleRowHandle(i);
if(!gridView1.IsGroupRow(rowHandle)) {
gridRow = gridView1.GetDataRow(rowHandle);
ds.Tables[0].Rows.Add(gridRow.ItemArray);
}
}
return ds;
}
private void Form1_Load(object sender, EventArgs e) {
this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
} private void simpleButton1_Click(object sender, EventArgs e) {
XtraReport1 report = new XtraReport1(checkEdit1.Checked ? FillDatasetFromGrid() : nwindDataSet, gridView1);
report.ShowDesignerDialog();
}
}}
可以直接给xtrareport 控件赋值