DEV 打印gridcontrl

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

}

上一篇:Android窗口管理服务WindowManagerService显示Activity组件的启动窗口(Starting Window)的过程分析


下一篇:Anagram字符串处理(STL真方便啊。。)