原文:动态传递参数到DevExpress.XtraReports的小结

前两种方法和WinForm一样,可以传递参数、数组、实体对象、DataTable等
1. 采用构造函数
具体用法:
在Report中
public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport
 {
    private int test1;       

    public Form1(int test1)
    {
        this.test1 = test1;
        InitializeComponent();
    }
}
调用Report
int test1 = 1;
XtraReport1 report = new XtraReport1(test1);
report.Show();

2.采用属性
具体用法:
在Report中
public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport
 {      
    public Form1()
    {
        InitializeComponent();
    }
    private int test1;  
    public int Test1
    {
        set { test1 = value; }
        get { return test1; }
    }
}
调用Report
XtraReport1 report = new XtraReport1();
report .Test1 = 1;
report.Show();

3.采用DataSet传递参数
在报表设计界面中,从工具栏数据中拉入DataSet到界面中,选择非类型化数据集,然后给拉入的DataSet添加Table和Column。报表界面的Field List中会自动加入刚添加进去的表和栏目,然后在拉动Field List栏中的Column到报表中,设计好後。在报表的代码中:
private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
 {
    this.DataSource = ds.Table[0];
}

我使用以上三种方法都没问题。

但我在允许用户修改报表设计
DevExpress.XtraReports.UI.XtraReport report = DevExpress.XtraReports.UI.XtraReport.FromFile(Application.StartupPath + "\\ReportTest.repx" );
report.ShowDesigner();
如果采用第1、2种方法,怎么也不行。后来只能变通,把要传递的数据保存在XML中,然后在Detail_BeforePrint事件中把XML文件中的数据读出来。

查看帮助说明如下:
in the assembly (represented by the .EXE or .DLL file) which produced the REPX file. Its path is also mentioned in the REPX file's header;

  1. in the current assembly where the FromFile method is called from;

  2. in the assemblies referenced by the current assembly.

If this class type is not found, then an instance of the XtraReport class is created.

Also, the saved state can be applied to the created report instance, if the loadState parameter is set to true.

等有空的时候使用反射试试,看能否让第1、2中传递参数的方法也可以实现用户自定义报表。

动态传递参数到DevExpress.XtraReports的小结的更多相关文章

  1. 通过List<String>动态传递参数给 sqlcommand.Parameters

    通过List<String>动态传递参数 private void GetallChecked_TreeNote(TreeNodeCollection aNodes, ref int To ...

  2. jqery autocomplete 动态传递参数的问题

    今天弄一个autocomplete 向后后台动态传递参数的问题 老的写法: params: { "saleid": $("#divSalesman input[field ...

  3. jquery.uploadify 动态传递参数

    最近 项目中使用到 uplaodify 来实现上传文件的功能.在传输动态参数的时候,遇到了问题! 使用官网提供的 settings 方法 官方例子function changeBtnText() {  ...

  4. AutoComplete的extraParams动态传递参数

    AutoComplete可利用extraParams传递参数,如 extraParams:{para1:'参数1',para2:'参数2'} 但是,如需动态取值作为参数值时却无法达到期望目的,可改为配 ...

  5. EasyUI Tree 动态传递参数

    1.问题背景 一般出现在加载的时候,传递参数给后台,进行数据筛选,然后在加载tree渲染数据.所谓动态参数,可以是你的上一级节点node,或者是根节点node. 2.涉及方法 onBeforeLoad ...

  6. struts2 redirect 配置动态传递参数

    <action name="actionName" class="com.towerking.TestAction" method="execu ...

  7. js用for循环为对象添加事件并传递参数

    var objArr = getObjArr(id);   for(var i=0; i<objArr.length; i++){    var param=objArr.param    ad ...

  8. java调用python脚本并向python脚本传递参数

    1.安装Eclipse 先安装jdk,再安装Eclipse,成功后开始建立py_java项目,在这个项目的存储目录SRC下建立test包,在test包中New-Class,新建MyDemo类,建好完成 ...

  9. 04发送请求,将值赋给data--动态传递参数

    03==>发送青丘,将值赋给data. 注意:赋值使用的是 _this.setData({ }) 是以冒号的形式赋值, 提前保存好this data: { arrlistdata:[], }, ...

随机推荐

  1. Duanxx的STM32学习: 启动模式,BOOT0和BOOT1具体解释

    在画STM32的电路图的时候,关于STM32的启动方式纠结了一下,现有的參考设计都是在STM32的启动选择引脚BOOT0和BOOT1上使用了跳帽,用以人工选择STM32的启动方式,可是在实际应用中这样 ...

  2. uva 1401 dp+Trie

    http://uva.onlinejudge.org/index.php? option=com_onlinejudge&Itemid=8&page=show_problem& ...

  3. Cocos2d-x 3.0final 终结者系列教程01-无论是从cocos2d-x2.x升级到版本cocos2d-x3.x

    诡谲的江湖,易变. 花花世界,车来人往. 最终确定.安家,将Cocos2d-x3.0final相关技术精加工的版本.并推出了博客文章, 不为他人,只为自己. 学习交流QQ群:301954471 --- ...

  4. [LeetCode290]Word Pattern

    题目: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full ...

  5. Java中使用Lua脚本语言(转)

    Lua是一个实用的脚本语言,相对于Python来说,比较小巧,但它功能并不逊色,特别是在游戏开发中非常实用(WoW采用的就是Lua作为脚本的).Lua在C\C++的实现我就不多说了,网上随便一搜,到处 ...

  6. REPLICAT RORA_1保持 ABENDED状态,无法启动问题处理

    REPLICAT  RORA_1保持 ABENDED状态,无法启动问题 环境: Item Source System Target System Platform Red Hat Enterprise ...

  7. LeetCode——ZigZag Conversion

    The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...

  8. Chapter 1 Securing Your Server and Network(3):使用托管服务帐号

    原文:Chapter 1 Securing Your Server and Network(3):使用托管服务帐号 原文出处:http://blog.csdn.net/dba_huangzj/arti ...

  9. (初稿)SQL Server 复制(Replication)系列(2)——事务复制搭建

    原文:(初稿)SQL Server 复制(Replication)系列(2)--事务复制搭建 本文演示如何搭建最基本的事务复制. 环境准备: 虚拟机2台: 服务器名分别为RepA和RepB,RepA为 ...

  10. Java TCP/UDP网络通信编程

    本文转自:http://www.cnblogs.com/cdtarena/archive/2013/04/10/3012282.html 网络应用中基本上都是TCP(Transmission Cont ...