本帖最后由 spring0906 于 2011-07-14 09:25:14 编辑

解决方案 »

  1.   

     //检索单据内容
                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, "打印错误");
                }
      

  2.   

    选择自定义custom....然后再选个什么设定。。2年不用,忘记了差不多也就是在那个选择纸张那一块就可以自己设定多少长宽了
      

  3.   


    刚刚找到个属性,跟starfd(2楼)说的差不多,设置纸张为customs 然后就可以自己设置尺寸,
    我所有的操作都是直接通过设计慢板设计的 现在我有在后台代码设置如何实现?
    代码设置有:
    1、定义打印尺寸(这个我已经知道了)
    2、自定义绑定列(就像水晶报表那样能通过各种方法设置绑定的列)
    3、代码绑定数据源(数据源为IList<>类型)
    4、如何设置报表中控件的值,比如(xraLabel)
    5、打印报错(报错信息如图)如何解决?
      

  4.   

    4、如何设置报表中控件的值,比如(xraLabel) 方案1;这个可以是有xtrareport 属性中的 datasourceschema(将数据表中的结构转换成xml格式,添加进去)在xraLabel中就可以直接手动选了
     方案3: 直接在报表的后台,通过传过来的数据直接赋值就可以(不过这个不能对细表自动进行汇总,上边的就可以)第五个问题,你打印的内容应该是超出了纸张的大小,调小下就可以
      

  5.   

    解决了 跟2楼说的差不多,设置为custom类型就可以设置大小了,关于报错的问题,暂时禁用错误提示就行了
      

  6.   

    兄弟,这个DevExpressXtraReport好用吗?是不是免费的呀?