因为引入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();
}

最新文章

  1. Jqgrid学习API
  2. JAVA访问权限
  3. Filter过滤的2种方式
  4. DrawingControl控件在Add Page时报故障的问题
  5. Java虚拟机工作原理详解 (一)
  6. SQL集合函数中利用case when then 技巧
  7. centos6.6下编译安装mysql5.6之后启动失败:Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
  8. poj 2688 状态压缩dp解tsp
  9. JavaScript回调函数的理解
  10. opengl离屏渲染(不需要和窗口绑定,仅当作一个可以渲染一张图片的API使用)+ opencv显示
  11. 1.5 sleep()方法
  12. 嵌入式Linux基于framebuffer的jpeg格式本地LCD屏显示
  13. Oracle复合B*tree索引branch block内是否包含非先导列键值?
  14. Counting Sort(Java)
  15. python第十天
  16. c3p0配置之preferredTestQuery参数默认值探秘
  17. 48-Python 安装pyautogui失败解决办法
  18. Real World Parsec --- 一个简便易学的 解释器
  19. 【leetcode】 Merge Intervals
  20. Hadoop 管理工具HUE配置-hdfs_clusters配置

热门文章

  1. (python笔记)python使用JS定位css元素
  2. Linux网络第六章:PXE高效批量网络装机及kickstart无人值守安装
  3. Linux安装Nginx安装并配置stream
  4. 【C++】fstream文件操作
  5. C# 查看变量的内存占用和分布
  6. 用Nodemailer发个邮件不算难?
  7. Day_1(并查集朋友圈、字典序排序)
  8. 遇到端口占用无法启动IIS Express服务器
  9. 读取数组树下的某值,并返回其父级下的任何值 vue
  10. Unity 在2D中实现LookAt,跟随鼠标转动