• 打印功能


    第一种方法:

    复制代码
                System.Drawing.Printing.PageSettings set_print_page = new System.Drawing.Printing.PageSettings();
                DevExpress.XtraPrinting.DynamicPrintHelper ph = new DevExpress.XtraPrinting.DynamicPrintHelper();
                if (ph.IsPrintingAvailable)
                {
                    ph.PageSettings = set_print_page;
                    ph.PageSettings.Landscape = true; 
                    ph.ShowPreview(this.gc, true);
                }
    复制代码

    第二种方法:

    复制代码
               if (DevExpress.XtraPrinting.PrintHelper.IsPrintingAvailable)
                {
                    DataRowView drv = (DataRowView)BS_Roads.Current;
                    PrintingSystem ps = new PrintingSystem();
                    PrintableComponentLink link = new PrintableComponentLink(ps);
                    link.Component = gc;
                    link.Landscape = true;
                    PageHeaderFooter phf = link.PageHeaderFooter as PageHeaderFooter;
                    phf.Header.Content.Clear();
                    phf.Header.Content.AddRange(new string[] { "", drv["线路名"].ToString() + "站点信息表", "" });
                    phf.Header.Font = new System.Drawing.Font("宋体", 16, System.Drawing.FontStyle.Regular);
                    phf.Header.LineAlignment = BrickAlignment.Center;
                    phf.Footer.Content.Clear();
                    phf.Footer.Content.AddRange(new string[] { "", String.Format("打印时间: {0:g}", DateTime.Now), "" });
                    link.CreateDocument();
                    link.ShowPreview();
                }
                else
                {
                    XtraMessageBox.Show("打印机不可用...", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
     
     

    #region 水印图片
    reportPrint.ShowPrintStatusDialog = false;

    #endregion

    PrintableComponentLink printLink = new PrintableComponentLink(reportPrint);
    reportPrint.Links.Add(printLink);
    printLink.Component = sheet;//这里可以是可打印的部件

    #region 报表的页眉页脚的设置
    PageHeaderFooter phf = printLink.PageHeaderFooter as PageHeaderFooter;
    phf.Header.Content.Clear();
    phf.Header.Content.AddRange(new string[] { "", printHeader, "" });
    phf.Header.Font = new System.Drawing.Font("微软雅黑", 14, System.Drawing.FontStyle.Bold);
    phf.Header.LineAlignment = BrickAlignment.Center;
    phf.Footer.Content.Clear();
    phf.Footer.Content.AddRange(new string[] { "", "", "第[页#]页 共 [页 #]页" });
    #endregion

  • 相关阅读:
    牛客练习赛64 C 序列卷积之和 (推式子 数学)
    HDU 汉诺塔系列
    牛客挑战赛40 A-小V和方程 (思维、数学、整数拆分、dp)
    HDU 2048 2049 (错位排列)
    组合数奇偶性判断
    bzoj 1249: SGU277 HERO
    CF70D Professor's task
    P3829 [SHOI2012]信用卡凸包
    CF316E3 Summer Homework
    P5284 [十二省联考2019]字符串问题
  • 原文地址:https://www.cnblogs.com/lvlaozf/p/12297792.html
Copyright © 2020-2023  润新知