DevExpress的GridControl如何實現打印和打印預覽 z


第一種方法:

            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);
            }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM