DevExpress.XtraGrid.GridControl 如何控制纵向和横向打印?

2024-12-26 17:52:50
推荐回答(2个)
回答1:

//打印
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();//进行预览
}

回答2:

//打印
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();//进行预览 }