Exemplo n.º 1
0
        /// <summary>
        /// Print the form
        /// </summary>
        public void PrintForm()
        {
            // Turn off the form
            layoutMain.Enabled = false;
            Application.DoEvents();


            // Reset the view
            foreach (GridColumn col in gridViewError.Columns)
            {
                if (col.FieldName.ToLower() == "ClassGenExceptionIconType".ToLower())
                {
                    col.Width   = 80;
                    col.Caption = "Error Type";
                }
            }

            // Print the grid
            mgDevX_GridControl_Print gridPrint =
                new mgDevX_GridControl_Print(gridViewError);

            gridPrint.ReportTitle = (!String.IsNullOrEmpty(_processDescription) ? _processDescription.Trim() + " - " : "") +
                                    "Error Listing...";
            DevExpress.XtraPrinting.Preview.PrintPreviewFormEx frm = gridPrint.ShowPreview(UserInterface.MainMDIForm);

            // Reset the columns
            foreach (GridColumn col in gridViewError.Columns)
            {
                if (col.FieldName.ToLower() == "ClassGenExceptionIconType".ToLower())
                {
                    col.Width = 35;
                    col.OptionsColumn.ShowCaption = false;
                }
            }

            layoutMain.Enabled = true;



            //// Check whether the XtraGrid control can be previewed.
            //if (!gridError.IsPrintingAvailable)
            //{
            //    MessageBox.Show("The 'DevExpress.XtraPrinting' library could not be found.", "Error");
            //    return;
            //}

            //// Turn off the form
            //layoutMain.Enabled = false;
            //Application.DoEvents();

            //gridViewError.OptionsPrint.EnableAppearanceEvenRow =
            //    gridViewError.OptionsPrint.EnableAppearanceOddRow =
            //    true;

            //PrintingSystem ps = new PrintingSystem();
            ////ps.PreviewFormEx.MdiParent = mwsLEAD.common.UserInterface._mainMDIForm;

            //ps.PreviewFormEx.SaveState = false;
            //ps.PreviewFormEx.PrintBarManager.MainMenu.Visible = false;
            //ps.PreviewFormEx.SaveState = true;


            //PrintableComponentLink link = new PrintableComponentLink(ps);
            //link.Component = gridError;
            //link.CreateMarginalHeaderArea += new CreateAreaEventHandler(link_CreateMarginalHeaderArea);
            //link.CreateMarginalFooterArea += new CreateAreaEventHandler(link_CreateMarginalFooterArea);
            //link.CreateDocument();

            //// Show the columns
            //foreach (GridColumn col in gridViewError.Columns)
            //{
            //    if (col.FieldName.ToLower() == "ClassGenExceptionIconType".ToLower())
            //    {
            //        col.Width = 80;
            //        col.Caption = "Error Type";
            //    }
            //}

            //// Opens the Preview window.
            //link.ShowPreview();
            //ps.PreviewFormEx.MdiParent = mwsCommon.UserInterface.MainMDIForm;
            //mwsCommon.UserInterface.FormFillsClientArea(ps.PreviewFormEx);

            //// Reset the columns
            //foreach (GridColumn col in gridViewError.Columns)
            //{
            //    if (col.FieldName.ToLower() == "ClassGenExceptionIconType".ToLower())
            //    {
            //        col.Width = 35;
            //        col.OptionsColumn.ShowCaption = false;
            //    }
            //}

            //// Turn off the form
            //layoutMain.Enabled = true;
        }
Exemplo n.º 2
0
 private void nbiPrintPreviewBars_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
 {
     using(DevExpress.XtraPrinting.Preview.PrintPreviewFormEx form = new DevExpress.XtraPrinting.Preview.PrintPreviewFormEx()) {
         PrintingSystem ps = new PrintingSystem();
         XtraReport1 report = new XtraReport1();
         form.PrintControl.PrintingSystem = ps;
         report.PrintingSystem = ps;
         report.CreateDocument();
         form.ShowDialog();
     }
 }