We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Printing many pages

Thread ID:

Created:

Updated:

Platform:

Replies:

25801 Mar 8,2005 02:16 AM Mar 9,2005 04:25 AM Windows Forms 3
loading
Tags: GridControl
Hoang Dinh
Asked On March 8, 2005 02:16 AM

Hi, I have an issue when print a grid have many pages. When I print a grid have many pages, but only the first page and the last page is printed. Many pages in the middle is blank. Please help me. Thanks,

Administrator [Syncfusion]
Replied On March 8, 2005 04:17 AM

This problem does not sound familiar. Are you using the latest 3.0.1.0 release? Do you see this problem in any of our samples? Do you see any exceptions being thrown while you are printing? Can you upload a sample project showing the problem?

Hoang Dinh
Replied On March 9, 2005 03:34 AM

I found this problem. Because I would like to print a title on the same pape with the grid ( the grid data is printed below a text title). Can you help me to resolve this problem? I can not attach my project so that you can reference the below sample code. Thank in advances, /*------------------------------------*/ using System; using System.Drawing; using System.Drawing.Printing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using Syncfusion.Windows.Forms.Grid; namespace PrintGrid { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private Syncfusion.Windows.Forms.Grid.GridDataBoundGrid gridDataBoundGrid1; private System.Windows.Forms.Button button1; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.gridDataBoundGrid1 = new Syncfusion.Windows.Forms.Grid.GridDataBoundGrid(); this.button1 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.gridDataBoundGrid1)).BeginInit(); this.SuspendLayout(); // // gridDataBoundGrid1 // this.gridDataBoundGrid1.AllowDragSelectedCols = true; this.gridDataBoundGrid1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.gridDataBoundGrid1.Location = new System.Drawing.Point(8, 8); this.gridDataBoundGrid1.Name = "gridDataBoundGrid1"; this.gridDataBoundGrid1.OptimizeInsertRemoveCells = true; this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = Syncfusion.Windows.Forms.Grid.GridShowCurrentCellBorder.GrayWhenLostFocus; this.gridDataBoundGrid1.Size = new System.Drawing.Size(608, 208); this.gridDataBoundGrid1.SmartSizeBox = false; this.gridDataBoundGrid1.SortBehavior = Syncfusion.Windows.Forms.Grid.GridSortBehavior.DoubleClick; this.gridDataBoundGrid1.TabIndex = 0; this.gridDataBoundGrid1.Text = "gridDataBoundGrid1"; this.gridDataBoundGrid1.UseListChangedEvent = true; // // button1 // this.button1.Location = new System.Drawing.Point(232, 224); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(96, 32); this.button1.TabIndex = 1; this.button1.Text = "Print"; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(624, 266); this.Controls.Add(this.button1); this.Controls.Add(this.gridDataBoundGrid1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.gridDataBoundGrid1)).EndInit(); this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { PrintDataBoundGrid(gridDataBoundGrid1,true); } private void Form1_Load(object sender, System.EventArgs e) { this.gridDataBoundGrid1.DataSource=InitTable(); } private DataTable InitTable() { DataTable retdat = new DataTable("SampleTable"); DataColumn[] myColumn = new DataColumn[]{ new DataColumn("Column0"), new DataColumn("Column1"), new DataColumn("Column2"), new DataColumn("Column3"), new DataColumn("Column4"), new DataColumn("Column5"), new DataColumn("Column6") }; retdat.Columns.AddRange(myColumn); DataRow dtRow; for(int i=0;i<500;i++) { dtRow = retdat.NewRow(); dtRow["Column0"] ="Column0"; dtRow["Column1"] ="Column1"; dtRow["Column2"] ="Column2"; dtRow["Column3"] ="Column3"; dtRow["Column4"] ="Column4"; dtRow["Column5"] ="Column5"; dtRow["Column6"] ="Column6"; retdat.Rows.Add(dtRow); } return retdat; } public void PrintDataBoundGrid(GridDataBoundGrid dtgbGrid,bool havegridline) { try { GridPrintDocument pd = new GridPrintDocument(dtgbGrid); //Assumes the default printer pd.DefaultPageSettings.Margins.Top+=50; pd.DefaultPageSettings.Margins.Left-=25; pd.DefaultPageSettings.Margins.Right-=25; pd.PrintPage+=new PrintPageEventHandler(pd_PrintPage); pd.PrintController=new StandardPrintController(); if(havegridline) { dtgbGrid.Properties.PrintHorzLines = true; dtgbGrid.Properties.PrintVertLines = true; dtgbGrid.Properties.PrintFrame=true; dtgbGrid.Properties.BackgroundColor=System.Drawing.Color.Transparent; } else { dtgbGrid.Properties.PrintHorzLines = false; dtgbGrid.Properties.PrintVertLines = false; dtgbGrid.Properties.PrintFrame=false; } dtgbGrid.Properties.CenterHorizontal=false; pd.Print(); } catch(Exception ex) { MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } private string title="Sample Text Title"; private Font titleFont=new Font("Arial",10); private void pd_PrintPage(object sender, PrintPageEventArgs e) { if(title!="") { Pen p=new Pen(Color.Black); e.Graphics.DrawString(title,titleFont,p.Brush,e.MarginBounds.Left,e.MarginBounds.Top-50); e.PageSettings.Margins.Top+=50; title=""; } } } } /*-------------------------*/

Administrator [Syncfusion]
Replied On March 9, 2005 04:25 AM

I got things to show it your code by doing this: Pen p=new Pen(Color.Black); e.PageSettings.Margins.Top-=50; //added e.Graphics.DrawString(title,titleFont,p.Brush,e.MarginBounds.Left,e.MarginBounds.Top-50); e.PageSettings.Margins.Top+=50; title="";

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;