Devexpress Xtrareport 创建主从报表
效果

xtrareport 布局

From 代码
private DataSet Getdata()
{
DataSet ds = new DataSet();
//config配置字符串
string constr=ConfigurationManager.ConnectionStrings["constr"].ToString();
SqlConnection mycon = new SqlConnection(constr);
try
{
mycon.Open(); //表1
SqlCommand mycom = new SqlCommand("select * from dp ", mycon);
SqlDataAdapter dpt = new SqlDataAdapter(mycom);
dpt.Fill(ds, "dp"); //表2
SqlCommand mycom2 = new SqlCommand("select * from duser ", mycon);
dpt = new SqlDataAdapter(mycom2);
dpt.Fill(ds, "duser");
mycon.Close(); //创建主外键
DataColumn parent = ds.Tables["dp"].Columns["dpid"];
DataColumn child = ds.Tables["duser"].Columns["dpid"]; //添加关系并指定为RelationColumn
DataRelation rel = new DataRelation("RelationColumn", parent, child);
ds.Relations.Add(rel); }
catch (Exception ex)
{ MessageBox.Show(ex.Message);
} return ds; } private void simpleButton1_Click(object sender, EventArgs e)
{
DataSet ds=Getdata();
XtraReport1 report = new XtraReport1(ds);
report.Landscape = true;
documentViewer1.DocumentSource = report;
report.CreateDocument();
}
}
Xtrareport 代码
public XtraReport1(DataSet ds)
{
InitializeComponent();
//绑定主表
this.DataSource = ds;
this.DataMember = "dp";
this.xrTableCell1.DataBindings.Add("Text", ds, "dp.dpname");
//指定从表成员
DetailReport.DataMember = "RelationColumn";
//绑定从表
DetailReport.DataSource = ds;
this.xrTableCell2.DataBindings.Add("Text", ds, "RelationColumn.userid");
this.xrTableCell3.DataBindings.Add("Text", ds, "RelationColumn.username"); }
注意事项
dataset数据集中绑定了两个表,一定要看清楚有没有填充进去,没有填充的话,从表不会显示数据的
Devexpress Xtrareport 创建主从报表的更多相关文章
- [原创]Devexpress XtraReports 系列 3 创建主从报表
昨天写了系列的第二篇Devexpress XtraReports 系列 2 创建表格报表 . 今天我们来继续系列 3 创建主从报表 首先我们来看看最后实现的效果.Demo最后附上. 开始吧. 第一步, ...
- [原创]Devexpress XtraReports 系列 5 创建交叉报表
昨天我们已经介绍了如何创建多栏报表,详见:[原创]Devexpress XtraReports 系列 4 创建多栏报表 今天我们继续我们的XtraReports系列.Demo和数据库文件最后会附上. ...
- [原创]Devexpress XtraReports 系列 6 创建并排报表
昨天我们已经介绍了如何创建交叉报表,详见:[原创]Devexpress XtraReports 系列 5 创建交叉报表 今天我们继续我们的XtraReports系列.Demo和数据库文件最后会附上. ...
- DevExpress XtraReports 入门四 创建 Web 报表
原文:DevExpress XtraReports 入门四 创建 Web 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更多的人不会像我这 ...
- Devexpress Xtrareport 并排报表
什么是并排报表呢? 按照我个人理解:并排报表是把两张或者两张以上的报表,放在一个报表页面. 注:为了方便,本示例使用同一个数据源,但是您可以使用相同的方法,而在一个报表文档中显示两个完全不同的 (使用 ...
- Devexpress Xtrareports 创建多栏报表
根据官方回答:多列或多行(取决于当前的多栏设置)呈现数据的报表 这种报表是有用的,例如,当每个明细区都只显示少量数据.并且需要在一列的右侧打印下一个明细区时,这样就能充分利用整个页面的宽度,此外,当创 ...
- [原创]Devexpress XtraReports 系列 2 创建表格报表
昨天发表了Devexpress XtraReports系列开篇,今天我们继续. 今天的主题是创建表格报表. 首先我们来看看最后实现的效果.Demo最后附上. 接下来开始讲解如何一步一步做出这个报表: ...
- [原创]Devexpress XtraReports 系列 8 创建Drill-Through报表
哎,今天公司工作忙了一天,一直没有时间写写东西.所以只能昨天晚上加班写咯.苦逼啊...... 昨天发表了Devexpress XtraReports系列第七篇[原创]Devexpress XtraRe ...
- [原创]Devexpress XtraReports 系列 10 创建标签报表
今天这篇是Dx Reports 基础初级系列的最后一篇了.以后如果有什么高级的应用,应该另开一个中级使用系列. 昨天发表了Devexpress XtraReports系列第九篇[原创]Devexpre ...
随机推荐
- (原创)团体程序设计天梯赛-练习集 L1-048 矩阵A乘以B (15 分)
给定两个矩阵A和B,要求你计算它们的乘积矩阵AB.需要注意的是,只有规模匹配的矩阵才可以相乘.即若A有Ra行.Ca列,B有Rb行.Cb列,则只有Ca与Rb相等时,两 ...
- 编译安装log4cxx
1.介绍 Log4cxx是开放源代码项目Apache Logging Service的子项目之一,是Java社区著名的log4j的c++移植版,用于为C++程序提供日志功能,以便开发者对目标程序进行调 ...
- H5教程(二),CSS入门(一)选择器
这是我的第二篇博客,H5教程CSS入门,适合刚开始学习H5的新手,让我们共同进步. 1. CSS简介 1.1 CSS是什么? CSS称为样式层叠表,是用于增强或控制网页样式,并允许将样式信息与网页 ...
- JavaScript——原生js实现瀑布流
瀑布流介绍及实现原理: 瀑布流是一种页面布局,页面上也有多等宽的块(块就页面内容),每一块都是绝对定位(absolute),每个块排列的方式如下:寻找现在高度最小的列,把该块定位到该列下方.需要知道, ...
- linux文件系统总结
apue中:其中进程表项内部的数组又称为 进程打开文件表 另外一个角度: 从linux内核角度开: task_struct是进程描述符对应上面的进程表项,在task_struct描述符中有str ...
- 牛客国庆集训day5 B 电音之王 (大数乘模)
链接:https://www.nowcoder.com/acm/contest/205/B来源:牛客网 题目描述 终于活成了自己讨厌的样子. 听说多听电音能加快程序运行的速度. 定义一个数列,告诉你a ...
- windows mysql导入sql文件
当需要的sql文件很大时(>200M)怎么办?答:修改my.ini文件,max_allowed_packet的值可以设置为1024M 进入mysql.exe目录下,执行如下命令: mysql - ...
- Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name"
解决办法
- 毕业设计 python opencv实现车牌识别 界面
主要代码参考https://blog.csdn.net/wzh191920/article/details/79589506 GitHub:https://github.com/yinghualuow ...
- ORA-01950:no privileges on tablespace 'USERS'
ORA-01950:no privileges on tablespace 'USERS' SQL>create user myuser identitied by password; SQL& ...