zoukankan      html  css  js  c++  java
  • 在 C# 中调用FastReport 设计窗口

    因为引入FastReport中的控件时报错,在网上又搜不到相应的解决办法

    所以在这里动态添加

    首先在创建的项目中引入FastReport.dll

                //创建一个空的报表
    Report report = new Report(); designerControl1.Report = report;
    //恢复设计布局 designerControl1.RefreshLayout(); panel2.Controls.Add(designerControl1); designerControl1.Dock
    = DockStyle.Fill; designerControl1.UIStateChanged += designerControl1_UIStateChanged;
            // 设计器ui改变事件
    private void designerControl1_UIStateChanged(object sender, EventArgs e) { // btnSave.Enabled = designerControl1.cmdSave.Enabled; // btnUndo.Enabled = designerControl1.cmdUndo.Enabled; // btnRedo.Enabled = designerControl1.cmdRedo.Enabled; }

    另一种方法 ,通过 report.Design(); 方法来调用设计器

                Report report = new Report();
                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                dt= DbHelperOra.Query(txt_Sql.Text).Tables[0];
                dt.TableName = "测试";
                DataTable dt1 = new DataTable("测试2");
                dt1.Columns.Add("时间");
                dt1.Columns.Add("打印人");
                dt1.Rows.Add("2020-01-01", "管理员");
                dt1.Rows.Add("2020-02-02", "管理");
                ds.Tables.Add(dt.Copy());
                ds.Tables.Add(dt1.Copy());
                report.RegisterData(ds);
                //动态添加参数
                report.SetParameterValue("测试参数名", "测试值");
                //获取指定名称的数据源
                report.GetDataSource("测试").Enabled = true;
                report.GetDataSource("测试2").Enabled = true;
                //调出设计器
                report.Design();
                //显示预览窗口
                report.Show();
                report.Dispose();

     打开报表不绑定数据是无法预览的

                Report report = new Report();
                OpenFileDialog openDlg = new OpenFileDialog();
                openDlg.Filter = "报表文件|*.frx";
                if (openDlg.ShowDialog() == DialogResult.OK)
                {
                    report.Load(openDlg.FileName);
                    report.Design();
                    report.Dispose();
                }

  • 相关阅读:
    为什么编程是独一无二的职业
    TSQL 编程规范
    Windows实战Git环境配置msysGit+TortoiseGit
    Linux环境下Socket编程
    数据持久化
    Javascript类的定义和引用
    详解C中volatile关键字
    ACM HDU 1040 As Easy As A+B
    ACM POJ 1753Flip Game
    ACM HDU 1017 A Mathematical Curiosity
  • 原文地址:https://www.cnblogs.com/iowoi/p/12987498.html
Copyright © 2011-2022 走看看