static未央

博客园 首页 新随笔 联系 订阅 管理

第一种方法:

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

 

 

posted on 2010-04-20 10:08  abstract未央  阅读(2865)  评论(2编辑  收藏  举报