/// <summary> /// 인쇄하기 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { ////https://documentation.devexpress.com/#WindowsForms/CustomDocument3427 if (this.xTabReport.SelectedTabPage == this.xPageResultSearch) { this.gridView1.ShowRibbonPrintPreview(); } else { CompositeLink comosLink = new CompositeLink(new PrintingSystem()); PrintableComponentLink pcLink1 = new PrintableComponentLink(); PrintableComponentLink pcLink2 = new PrintableComponentLink(); PrintableComponentLink pcLink3 = new PrintableComponentLink(); pcLink1.Component = this.gridYear; pcLink2.Component = this.gridMonth; pcLink3.Component = this.gridDays; comosLink.Links.Add(pcLink1); comosLink.Links.Add(pcLink2); comosLink.Links.Add(pcLink3); this.PrintInit(comosLink.PrintingSystemBase); comosLink.ShowRibbonPreviewDialog(this.LookAndFeel); } }
/// <summary> /// 预览当前设计Bom信息 /// </summary> private void btnPreview_Click(object sender, EventArgs e) { try { if (!FrmMainDAO.QueryUserButtonPower(this.Name, this.Text, sender, true)) { return; } if (treeListDesignBom.Nodes.Count > 0) { //treeListDesignBom.ShowPrintPreview(); CompositeLink compLink = new CompositeLink(new PrintingSystem()); PrintableComponentLink treeListLink = new PrintableComponentLink(); treeListLink.Component = treeListDesignBom; compLink.PaperKind = System.Drawing.Printing.PaperKind.A4;//设置纸张大小 System.Drawing.Printing.Margins margins = new System.Drawing.Printing.Margins(50, 50, 100, 50); compLink.Margins = margins; PageHeaderFooter phf = compLink.PageHeaderFooter as PageHeaderFooter; phf.Header.Content.Clear(); phf.Header.Content.AddRange(new string[] { "", "设计Bom登记单", "" }); phf.Header.Font = new System.Drawing.Font("宋体", 22, System.Drawing.FontStyle.Bold); phf.Header.LineAlignment = BrickAlignment.Center; phf.Footer.Content.AddRange(new string[] { "", String.Format("打印时间: {0:g}", DateTime.Now), "" }); Link headerLink = new Link(); headerLink.CreateDetailArea += new CreateAreaEventHandler(HeaderLink_CreateDetailArea); compLink.Links.Add(headerLink); compLink.Links.Add(treeListLink); compLink.ShowRibbonPreviewDialog(treeListDesignBom.LookAndFeel); } } catch (Exception ex) { ExceptionHandler.HandleException(this.Text + "--预览当前设计Bom信息错误。", ex); } }