DevGridControl通用打印方法,调用PrintableComponentLink组件

  1. 通用的GridControl.mmPrint打印方法,调用Dev本身的PrintableComponentLink组件 

   

        public void mmPrint()
        {
            using (DevExpress.XtraPrinting.PrintableComponentLink vPrintComp1 = new DevExpress.XtraPrinting.PrintableComponentLink(new PrintingSystem()))
            {
                vPrintComp1.Component = this;
                vPrintComp1.Landscape = true;
                vPrintComp1.PaperKind = this._mpPrintPaperKind;
                vPrintComp1.CreateMarginalHeaderArea += this.myEvent_CreateMarginalHeaderArea;
                //vPrintComp1.Margins.Left / .Top 
                vPrintComp1.CreateDocument();
                vPrintComp1.ShowPreview();
            }
        }

   

   2. 打印格式事件CreateMarginalHeaderArea:

 1         private void myEvent_CreateMarginalHeaderArea(object sender, CreateAreaEventArgs e)
 2         {
 3             string vReportTitle = this.FindForm().Text.Trim().mmGetSplitLeftString("[");
 4             PageInfoBrick vPageInfoBrick1 = e.Graph.DrawPageInfo(PageInfo.None, vReportTitle, Color.DarkBlue,
 5                new RectangleF(0, 0, 100, 21), BorderSide.None);
 6             vPageInfoBrick1.LineAlignment = BrickAlignment.Center;
 7             vPageInfoBrick1.Alignment = BrickAlignment.Center;
 8             vPageInfoBrick1.AutoWidth = true;
 9             vPageInfoBrick1.Font = new System.Drawing.Font("宋体", 11f, FontStyle.Bold);
10         }
posted @ 2012-09-03 10:43  C#老头子  Views(2218)  Comments(0Edit  收藏  举报