Esempio n. 1
0
        /// <summary>
        /// Preview the content of the grid to be print
        /// </summary>
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                this.gridControl1.Model.Properties.PrintFrame = false;

                Syncfusion.GridHelperClasses.GridPrintDocumentAdv pd = new Syncfusion.GridHelperClasses.GridPrintDocumentAdv(this.gridControl1);
                pd.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(25, 25, 25, 25);

                if (this.ShowHeaderFooter.Checked)
                {
                    pd.HeaderHeight = 70;
                    pd.FooterHeight = 50;
                }
                else
                {
                    pd.HeaderHeight = 0;
                    pd.HeaderHeight = 0;
                }

                pd.ScaleColumnsToFitPage = this.ScaleColumnsToFit.Checked;

                pd.DrawGridPrintHeader += new Syncfusion.GridHelperClasses.GridPrintDocumentAdv.DrawGridHeaderFooterEventHandler(pd_DrawGridPrintHeader);
                pd.DrawGridPrintFooter += new Syncfusion.GridHelperClasses.GridPrintDocumentAdv.DrawGridHeaderFooterEventHandler(pd_DrawGridPrintFooter);

                PrintPreviewDialog previewDialog = new PrintPreviewDialog();
                previewDialog.Document = pd;
                previewDialog.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while print preview" + ex.ToString());
            }
        }
Esempio n. 2
0
        //Used to create customized Printpreview dialog
        private void PrintPreview_Click(object sender, EventArgs e)
        {
            try
            {
                this.gridGroupingControl1.TableModel.Properties.PrintFrame = false;

                Syncfusion.GridHelperClasses.GridPrintDocumentAdv pd = new Syncfusion.GridHelperClasses.GridPrintDocumentAdv(this.gridGroupingControl1.TableControl);
                pd.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(25, 25, 25, 25);

                //Set header and footer height
                if (this.ShowHeaderFooter.Checked)
                {
                    pd.HeaderHeight = 70;
                    pd.FooterHeight = 50;
                }
                else
                {
                    pd.HeaderHeight = 0;
                    pd.HeaderHeight = 0;
                }

                //Whether scale columns to fit
                pd.ScaleColumnsToFitPage = this.ScaleColumnsToFit.Checked;

                //Handle the events to draw the header / footer
                pd.DrawGridPrintHeader += new Syncfusion.GridHelperClasses.GridPrintDocumentAdv.DrawGridHeaderFooterEventHandler(pd_DrawGridPrintHeader);
                pd.DrawGridPrintFooter += new Syncfusion.GridHelperClasses.GridPrintDocumentAdv.DrawGridHeaderFooterEventHandler(pd_DrawGridPrintFooter);

                PrintPreviewDialog previewDialog = new PrintPreviewDialog();
                previewDialog.Document = pd;
                previewDialog.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while print preview" + ex.ToString());
            }
        }