77范文网 - 专业文章范例文档资料分享平台

FastReport报表使用代码C#

来源:网络收集 时间:2019-04-09 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

using System;

using System.Data;

using System.ComponentModel; using FastReport;

namespace cx {

///

/// Summary description for FrxDataSet. ///

public class FrxDataTable : DataTable {

private int nItem;

TfrxUserDataSetClass m_ds;

private DataTable m_ChildTable;

public new string TableName {

get { return m_ds.Name; } }

public IfrxDataSet FrxTable {

get { return m_ds as IfrxDataSet; } }

private void constructor(string name) {

m_ChildTable = null;

m_ds = new TfrxUserDataSetClass();

m_ds.OnCheckEOF += new

IfrxUserDataSetEvents_OnCheckEOFEventHandler(OnCheckEOFEventHandler); m_ds.OnGetValue += new

IfrxUserDataSetEvents_OnGetValueEventHandler(OnGetValueHandler); m_ds.OnFirst += new

IfrxUserDataSetEvents_OnFirstEventHandler(OnFirstEventHandler); m_ds.OnNext += new

IfrxUserDataSetEvents_OnNextEventHandler(OnNextEventHandler); m_ds.OnPrior += new

IfrxUserDataSetEvents_OnPriorEventHandler(OnPriorEventHandler);

m_ds.Name = name;

DataColumnCollection cols = Columns; cols.CollectionChanged += new

CollectionChangeEventHandler(ColumnsCollection_Changed);

纪兆亮自学FastReport 1

}

public FrxDataTable(string name) {

constructor(name); }

public FrxDataTable(DataTable t) {

constructor(t.TableName); string FieldNames = null;

foreach (DataColumn col in t.Columns) FieldNames += col.Caption + \; m_ds.Fields = FieldNames; m_ChildTable = t; }

///

/// Assigns table to report ///

public void AssignToDataBand(string BandName, TfrxReportClass report) {

IfrxComponent frx_component;

((IfrxComponent)report).FindObject(BandName, out frx_component); ((IfrxDataBand)frx_component).DataSet = (IfrxDataSet)m_ds; }

///

/// Assigns table to report ///

public void AssignToReport(bool Enable, TfrxReportClass report) {

report.SelectDataset(Enable, m_ds); }

///

/// On First event handler ///

private void OnFirstEventHandler() {

nItem = 0; }

///

/// On Next event handler ///

private void OnNextEventHandler() {

纪兆亮自学FastReport 2

nItem++; }

///

/// On Prior evene handler ///

private void OnPriorEventHandler() {

nItem--; }

///

/// On check EndOfFile event handler ///

private void OnCheckEOFEventHandler(out bool eof) {

if (m_ChildTable == null) {

eof = (nItem >= Rows.Count); } else {

eof = (nItem >= m_ChildTable.Rows.Count); } }

///

/// On get value handler ///

private void OnGetValueHandler(object VarName, out object Val) {

if (m_ChildTable == null) {

Val = Rows[nItem][VarName.ToString()]; } else {

Val = m_ChildTable.Rows[nItem][VarName.ToString()]; }

// FastReport does not know about System.Decimal object type // so convert it to Integer if (Val is Decimal) {

Val = Decimal.ToInt32((Decimal)Val); } }

纪兆亮自学FastReport 3

///

/// Updates FastReport UserDataSet on Column addition ///

private void ColumnsCollection_Changed(object sender, CollectionChangeEventArgs e) {

DataColumnCollection cols = (DataColumnCollection)sender; string FieldNames = null;

foreach (DataColumn col in cols) FieldNames += col.Caption + \; m_ds.Fields = FieldNames; } } }

Button按钮中的代码 引用FastReport

FastReport.TfrxReportClass report = new FastReport.TfrxReportClass(); report.MainWindowHandle = (int)this.Handle;

report.LoadReportFromFile(Application.StartupPath + \);

alluse.FrxDataTable rptdataset1 = new alluse.FrxDataTable(\); SqlDataAdapter sda = new SqlDataAdapter(\, alluse.Class1.conn1);

sda.Fill(rptdataset1);

rptdataset1.AssignToReport(true, report);

rptdataset1.AssignToDataBand(\, report);// MasterData1报表中的主数据

report.ShowReport();

以上是成功代码。。。。。。。。。。。。

private void button2_Click(object sender, EventArgs e) {

FastReport.TfrxReportClass report = new FastReport.TfrxReportClass(); report.MainWindowHandle = (int)this.Handle;

report.LoadReportFromFile(\添加报表路径 FrxDataTable rptdataset1 = new FrxDataTable(\

FrxDataTable rptdataset2 = new FrxDataTable(\

OleDbDataAdapter oleDbDataAdapter1 = new OleDbDataAdapter(\* from TZ_Unit\

oleDbDataAdapter1.Fill(rptdataset1);

OleDbDataAdapter oleDbDataAdapter2 = new OleDbDataAdapter(listsql, Class1.conn1);

oleDbDataAdapter2.Fill(rptdataset2);

// rptdataset1.AssignToReport(true, report); // rptdataset2.AssignToReport(true, report);

// rptdataset2.AssignToDataBand(\

report.ShowReport(); }

4

纪兆亮自学FastReport

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库FastReport报表使用代码C#在线全文阅读。

FastReport报表使用代码C#.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/583643.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: