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 ...
随机推荐
- 消息队列开发记录笔记-ActiveMQ
1.下载ActiveMQ 去官方网站下载:http://activemq.apache.org/ 2.运行ActiveMQ 解压缩apache-activemq-5.5.1-bin.zip,然后双击a ...
- tomcat - 认识
tomcat - web应用服务器 环境:ubuntu测试 @shell命令(cd到tomcat目录下) 启动: ./bin startup.sh 关闭:./bin shutdown.sh @部署 ...
- windows 注册表
注册表(Registry,繁体中文版Windows称之为登录)是Microsoft Windows中的一个重要的数据库,用于存储系统和应用程序的设置信息.早在Windows 3.0推出OLE技术的时候 ...
- hdu1845(a^b的因子和%p)
题目链接:http://poj.org/problem?id=1845 思路: 1.整数唯一分解定理: 任意正整数都有且只有一种方式写出其素因子的乘积表达式. a=(p1^k1)*(p2^k2)*(p ...
- git pull 命令
作用:取回远程主机某个分支的更新,再与本地的指定分支合并 格式:git pull <远程主机名> <远程分支名>:<本地分支名> 1. 如果与当前分支合并,则可省 ...
- Qt 学习之路 2(1):序
https://www.devbean.net/category/qt-study-road-2/page/10 原来开过QT学习之路1, 很棒, 再翻阅时已经没有了. 所以这次把看过的记录下来 Ho ...
- 奇妙的 clip-path 几何图形
CSS 新属性 clip-path,意味裁剪路径的意思,让我们可以很便捷的生成各种几何图形. clip-path 通过定义特殊的路径,实现我们想要的图形.而这个路径,正是 SVG 中的 path . ...
- Liunx php函数 smtp 发送邮件
1. 查看防火墙是否开放端口 默认smtp 25 iptables -L -n 如果没有,添加25端口 iptables -A INPUT -p tcp --dport 25 -j ACCEPT ip ...
- Go语言基础之5--数组(array)和切片(slince)
一.数组(array) 1.1 数组定义 1)含义: 数组是同一类型的元素集合. 数组是具有固定长度并拥有零个或者多个相同数据类型元素的序列. 2)定义一个数组的方法: var 变量名[len] ty ...
- Swagger的坑
swagger.pathPatterns如果是譬如/w/.*,那么如果API中以w开头的描述就会在swagger-ui中显示不出来