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 ...
随机推荐
- Hadoop单机/伪分布式集群搭建(新手向)
此文已由作者朱笑笑授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 本文主要参照官网的安装步骤实现了Hadoop伪分布式集群的搭建,希望能够为初识Hadoop的小伙伴带来借鉴意 ...
- Locust压力测试使用总结
https://blog.csdn.net/jojoy_tester/article/details/77926470 参考网址 上次做接口压力测试前一直研究使用jmeter,本以为可以拿来使用了, ...
- poj1195(二维树状数组)
题目链接:https://vjudge.net/problem/POJ-1195 题意:有s*s的矩阵,初始化为全0,有两种操作,单点修改(x,y)的值,区间查询(x,y)的值(l<=x< ...
- ubuntu - 14.04,安装VirtualBox 5.0(虚拟机软件)!
VirtualBox是一款免费.开源的虚拟机软件,可以运行在多种操作系统上,真的是一款值得我们使用的虚拟机软件! 官方网址:https://www.virtualbox.org/ ubuntu14.0 ...
- loj#6363. 「地底蔷薇」(拉格朗日反演+多项式全家桶)
题面 传送门 题解 肝了一个下午--我老是忘了拉格朗日反演计算的时候多项式要除以一个\(x\)--结果看它推倒简直一脸懵逼-- 做这题首先你得知道拉格朗日反演是个什么东西->这里 请坐稳,接下来 ...
- 洛谷P3709 大爷的字符串题(莫队)
题目背景 在那遥远的西南有一所学校 /*被和谐部分*/ 然后去参加该省省选虐场 然后某蒟蒻不会做,所以也出了一个字符串题: 题目描述 给你一个字符串a,每次询问一段区间的贡献 贡献定义: 每次从这个区 ...
- 2.Valid Parentheses (括号匹配)
Level: Easy 题目描述: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', ...
- 查看详细linux系统信息的命令和方法
查看内存大小: cat /proc/meminfo |grep MemTotaluname -a # 查看内核/操作系统/CPU信息的linux系统信息命令head -n 1 /etc/issue # ...
- msf连接PostgreSQL数据库
一.启动PostgreSQL服务######################################################################?root@root:~# ...
- beego 连接postgres
package main import ( "fmt" "github.com/astaxie/beego/orm" "mybee/models&qu ...