博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DEV 打印gridcontrl
阅读量:5142 次
发布时间:2019-06-13

本文共 1434 字,大约阅读时间需要 4 分钟。

   private void PrintPreview(DevExpress.XtraPrinting.IPrintable gridControlPrint)

        {
            DevExpress.XtraPrintingLinks.CompositeLink compositeLink = new DevExpress.XtraPrintingLinks.CompositeLink();
            DevExpress.XtraPrinting.PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem();
            //设置左右间距
            compositeLink.Margins.Left = 10;
            compositeLink.Margins.Right = 10;
            ///设置页眉
           
            PageHeaderFooter phf = compositeLink.PageHeaderFooter as PageHeaderFooter;
            phf.Header.Content.Clear();
            phf.Header.Content.AddRange(new string[] { "", SqlHlperClass.SelectTable("select * from sys_corporation").Rows[0][0]+" " +cmbGS.Text, "" });
            phf.Header.LineAlignment = BrickAlignment.Center;
            phf.Header.Font = new Font("黑体", 22, FontStyle.Bold);

            ps.Graph.ForeColor = Color.Red;//.Font = new Font("黑体", 10, FontStyle.Bold);

            compositeLink.PrintingSystem = ps;
            compositeLink.Landscape = false;  //横向

            compositeLink.PaperKind = System.Drawing.Printing.PaperKind.A4;   //纸张

            DevExpress.XtraPrinting.PrintableComponentLink link = new
               DevExpress.XtraPrinting.PrintableComponentLink(ps);

           

            ps.PageSettings.Landscape = false;   //横向

            link.Component = gridControlPrint;

            compositeLink.Links.Add(link);

           // ps.PageSettings.Assign(new Margins(0, 0, 0, 0), new Margins(0, 0, 0, 0), PaperKind.Custom, new Size(300, 400), false);

           // ps.PageSettings.RightMargin = 0;

            link.CreateDocument();  //建立文档

          ps.PreviewFormEx.Show();//进行预览 
            //  ps.Print();

        }

 

转载于:https://www.cnblogs.com/jiangu66/p/3192263.html

你可能感兴趣的文章