DevExpress中XtraReport如何控制打印尺寸大小 困我好几天了 !!!! 本帖最后由 spring0906 于 2011-07-14 09:25:14 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //检索单据内容 Share.ShareData ssd = new Share.ShareData(); ssd = Share.Funtions.BytesToShareData(Common.GlobalVar.Webinv.GetTransferorderforprint(strbillNumber)); //检索后 设置参数,如是否立即生效等 //const string tbNameBillType = "打印参数"; string rptAss = Convert.ToString(ssd.ADataSet.Tables["Print"].Rows[0]["RptAssembly"]); string rptName = Convert.ToString(ssd.ADataSet.Tables["Print"].Rows[0]["RptFormName"]); try { System.Reflection.Assembly asm = System.Reflection.Assembly.Load(rptAss);//程序集名 object rptObj = asm.CreateInstance("easyDms." + rptName, false, System.Reflection.BindingFlags.Default, null, null, null, null);//程序集+form的类名。 DevExpress.XtraReports.UI.XtraReport xrp2 = (DevExpress.XtraReports.UI.XtraReport)rptObj; xrp2.DataSource = ssd.ADataSet; //PrintingSystem prn = new PrintingSystem(); //设置打印页的宽度和高度 xrp2.ReportUnit = DevExpress.XtraReports.UI.ReportUnit.TenthsOfAMillimeter; //设置单位为mm xrp2.PaperKind = System.Drawing.Printing.PaperKind.Custom; //纸张类型自定义 try { xrp2.PageHeight = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageHeight"]); xrp2.PageWidth = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageWidth"]); //边距 for (int i = 0; i < xrp2.Bands.Count; i++) { if (xrp2.Bands[i].GetType().ToString() == "DevExpress.XtraReports.UI.TopMarginBand") xrp2.Bands[i].HeightF = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageTop"]) * 10; if (xrp2.Bands[i].GetType().ToString() == "DevExpress.XtraReports.UI.BottomMarginBand") xrp2.Bands[i].HeightF = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageBottom"]) * 10; } xrp2.Margins.Left = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageLeft"]) * 10; xrp2.Margins.Right = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageRight"]) * 10; } catch { //如果有错误,则取默认打印机的默认纸张 PrintDocument pd = new PrintDocument(); xrp2.PageHeight = Convert.ToInt16(pd.DefaultPageSettings.PaperSize.Height / 0.394); xrp2.PageWidth = Convert.ToInt16(pd.DefaultPageSettings.PaperSize.Width / 0.394); MessageBox.Show("打印页面设置不正确,使用默认纸张设置。", "提示"); } //生成打印内容 xrp2.CreateDocument(); xrp2.ShowPreviewDialog(); //显示单据 //easyDms.Common.FormTempletPrint wprint = new easyDms.Common.FormTempletPrint(); //显示打印窗口 //wprint.printingSystem = (PrintingSystem)xrp2.PrintingSystem; //wprint.ShowDialog(); } catch (Exception ex) { Common.PubFuntion.MessageInfo(ex.Message, "打印错误"); } 选择自定义custom....然后再选个什么设定。。2年不用,忘记了差不多也就是在那个选择纸张那一块就可以自己设定多少长宽了 刚刚找到个属性,跟starfd(2楼)说的差不多,设置纸张为customs 然后就可以自己设置尺寸,我所有的操作都是直接通过设计慢板设计的 现在我有在后台代码设置如何实现?代码设置有:1、定义打印尺寸(这个我已经知道了)2、自定义绑定列(就像水晶报表那样能通过各种方法设置绑定的列)3、代码绑定数据源(数据源为IList<>类型)4、如何设置报表中控件的值,比如(xraLabel)5、打印报错(报错信息如图)如何解决? 4、如何设置报表中控件的值,比如(xraLabel) 方案1;这个可以是有xtrareport 属性中的 datasourceschema(将数据表中的结构转换成xml格式,添加进去)在xraLabel中就可以直接手动选了 方案3: 直接在报表的后台,通过传过来的数据直接赋值就可以(不过这个不能对细表自动进行汇总,上边的就可以)第五个问题,你打印的内容应该是超出了纸张的大小,调小下就可以 解决了 跟2楼说的差不多,设置为custom类型就可以设置大小了,关于报错的问题,暂时禁用错误提示就行了 兄弟,这个DevExpressXtraReport好用吗?是不是免费的呀? 如何用正则分离一个HTML块?谢谢。 水晶报表的参数传递问题? 如何在vs2005中安装AjaxPro组件 VS2008使用中遇到的问题 C#继承机制的疑惑--------看得头有点晕。 KeyPress中默认的处理是什么???? 子窗体B关闭后调用父窗体A中的refreshMainForm(),怎么父窗体A中TreeView没有被刷新? 在线等,急,我是从学者,请各位帮忙 算术表达式解释 299元最低价参加微软TechED-2001技术教育大会 女友的生日马上就要到了,想自己写个程序送给她做生日礼物(求思路) C#小白问题
Share.ShareData ssd = new Share.ShareData();
ssd = Share.Funtions.BytesToShareData(Common.GlobalVar.Webinv.GetTransferorderforprint(strbillNumber)); //检索后 设置参数,如是否立即生效等
//const string tbNameBillType = "打印参数";
string rptAss = Convert.ToString(ssd.ADataSet.Tables["Print"].Rows[0]["RptAssembly"]);
string rptName = Convert.ToString(ssd.ADataSet.Tables["Print"].Rows[0]["RptFormName"]); try
{
System.Reflection.Assembly asm = System.Reflection.Assembly.Load(rptAss);//程序集名
object rptObj = asm.CreateInstance("easyDms." + rptName, false, System.Reflection.BindingFlags.Default, null, null, null, null);//程序集+form的类名。 DevExpress.XtraReports.UI.XtraReport xrp2 = (DevExpress.XtraReports.UI.XtraReport)rptObj;
xrp2.DataSource = ssd.ADataSet;
//PrintingSystem prn = new PrintingSystem();
//设置打印页的宽度和高度
xrp2.ReportUnit = DevExpress.XtraReports.UI.ReportUnit.TenthsOfAMillimeter; //设置单位为mm
xrp2.PaperKind = System.Drawing.Printing.PaperKind.Custom; //纸张类型自定义
try
{
xrp2.PageHeight = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageHeight"]);
xrp2.PageWidth = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageWidth"]); //边距
for (int i = 0; i < xrp2.Bands.Count; i++)
{
if (xrp2.Bands[i].GetType().ToString() == "DevExpress.XtraReports.UI.TopMarginBand")
xrp2.Bands[i].HeightF = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageTop"]) * 10; if (xrp2.Bands[i].GetType().ToString() == "DevExpress.XtraReports.UI.BottomMarginBand")
xrp2.Bands[i].HeightF = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageBottom"]) * 10;
} xrp2.Margins.Left = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageLeft"]) * 10;
xrp2.Margins.Right = Convert.ToInt16(ssd.ADataSet.Tables["Print"].Rows[0]["PageRight"]) * 10; }
catch
{
//如果有错误,则取默认打印机的默认纸张
PrintDocument pd = new PrintDocument();
xrp2.PageHeight = Convert.ToInt16(pd.DefaultPageSettings.PaperSize.Height / 0.394);
xrp2.PageWidth = Convert.ToInt16(pd.DefaultPageSettings.PaperSize.Width / 0.394);
MessageBox.Show("打印页面设置不正确,使用默认纸张设置。", "提示");
} //生成打印内容
xrp2.CreateDocument();
xrp2.ShowPreviewDialog(); //显示单据
//easyDms.Common.FormTempletPrint wprint = new easyDms.Common.FormTempletPrint();
//显示打印窗口
//wprint.printingSystem = (PrintingSystem)xrp2.PrintingSystem;
//wprint.ShowDialog();
}
catch (Exception ex)
{
Common.PubFuntion.MessageInfo(ex.Message, "打印错误");
}
刚刚找到个属性,跟starfd(2楼)说的差不多,设置纸张为customs 然后就可以自己设置尺寸,
我所有的操作都是直接通过设计慢板设计的 现在我有在后台代码设置如何实现?
代码设置有:
1、定义打印尺寸(这个我已经知道了)
2、自定义绑定列(就像水晶报表那样能通过各种方法设置绑定的列)
3、代码绑定数据源(数据源为IList<>类型)
4、如何设置报表中控件的值,比如(xraLabel)
5、打印报错(报错信息如图)如何解决?
方案3: 直接在报表的后台,通过传过来的数据直接赋值就可以(不过这个不能对细表自动进行汇总,上边的就可以)第五个问题,你打印的内容应该是超出了纸张的大小,调小下就可以