1. 程式人生 > >C# DevExpress 自定義列印(設定橫向列印為例)。

C# DevExpress 自定義列印(設定橫向列印為例)。

   //列印
        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();//進行預覽  

        }