DevExpress.XtraGrid.GridControl 打印

//打印
        private void btnPrint_Click(object sender, EventArgs e)
        {
              PrintPreview(this.gridControl1);
        }


  //自定义打印
        private void PrintPreview(DevExpress.XtraPrinting.IPrintable gridControlPrint)
        {
            DevExpress.XtraPrintingLinks.CompositeLink compositeLink = new DevExpress.XtraPrintingLinks.CompositeLink();
            DevExpress.XtraPrinting.PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem();

            compositeLink.PrintingSystem = ps;
            compositeLink.Landscape = true;  //横向
            compositeLink.PaperKind = System.Drawing.Printing.PaperKind.A4;   //纸张
            DevExpress.XtraPrinting.PrintableComponentLink link = new         DevExpress.XtraPrinting.PrintableComponentLink(ps);


            ps.PageSettings.Landscape = true;   //横向
            link.Component = gridControlPrint;
            compositeLink.Links.Add(link);

            link.CreateDocument();  //建立文档
            ps.PreviewFormEx.Show();//进行预览  

        }

你可能感兴趣的:(DevExpress.XtraGrid.GridControl 打印)