Print problem

When a cell contains multiple lines of text, the last line is not printed. Since i couldnt attach the file.. I am giving the sample code here. using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WindowsApplication1 { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private Syncfusion.Windows.Forms.Grid.GridControl gridControl1; /// /// 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 // gridControl1.RowCount = 2; gridControl1.ColCount = 2; } /// /// 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.button1 = new System.Windows.Forms.Button(); this.gridControl1 = new Syncfusion.Windows.Forms.Grid.GridControl(); ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(576, 376); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(88, 32); this.button1.TabIndex = 0; this.button1.Text = "Print Preview"; this.button1.Click += new System.EventHandler(this.button1_Click); // // gridControl1 // this.gridControl1.Location = new System.Drawing.Point(40, 24); this.gridControl1.Name = "gridControl1"; this.gridControl1.Size = new System.Drawing.Size(736, 352); this.gridControl1.TabIndex = 1; this.gridControl1.Text = "gridControl1"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(880, 429); this.Controls.Add(this.gridControl1); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit(); this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { gridControl1[1,1].CellValue = "This is single line"; gridControl1[1,2].CellValue = "This is going to be (This text is to increase the width)a multiple line in the grid "+System.Environment.NewLine+ "This is the second line in the cell"+System.Environment.NewLine+ "Check this line is printed correctly"; gridControl1.ColWidths.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Col(2),Syncfusion.Windows.Forms.Grid.GridResizeToFitOptions.IncludeHeaders); gridControl1.RowHeights.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Row(1),Syncfusion.Windows.Forms.Grid.GridResizeToFitOptions.IncludeHeaders); } private System.Drawing.Printing.PrintDocument GetDoc() { Syncfusion.Windows.Forms.Grid.GridPrintDocument doc = new Syncfusion.Windows.Forms.Grid.GridPrintDocument(this.gridControl1, true); return doc; } private void button1_Click(object sender, System.EventArgs e) { System.Drawing.Printing.PrintDocument printDoc = GetDoc(); System.Windows.Forms.PrintPreviewDialog pdlg = new PrintPreviewDialog(); pdlg.Document = printDoc; pdlg.ShowDialog(); } } } When you run this sample code you will find a form with a gridcontrol containing two rows and two columns. Also the form will contain a printpreview button. When you click this you will notice that the last line in the second column of first row is not printed.

4 Replies

AD Administrator Syncfusion Team March 11, 2005 09:08 AM UTC

Adding this line at the top of your formload made the display and previewed grid appear the same. this.gridControl1.BaseStylesMap["Standard"].StyleInfo.Font.Unit = GraphicsUnit.World;


AD Administrator Syncfusion Team March 11, 2005 01:44 PM UTC

if i am using the font name and size properties for the cell as follows. gridControl1[1,2].Font.Facename="courier new"; gridControl1[1,2].Font.Size=10; I use this in Form_load. Now when i use the following line this.gridControl1.BaseStylesMap["Standard"].StyleInfo.Font.Unit = GraphicsUnit.World; in form load the font size and face are not displayed in the grid and also in printpreview. I want to preserve the font size and font face. Thanks Clay


AD Administrator Syncfusion Team March 11, 2005 06:05 PM UTC

You should be able to see the font in PrintPreview and on the screen. The size may be scaled slightly differently. The only other way I know to try to avoid this problem is to snap a bitmap of the grid and then print this bitmap. But this has problems because the scaling the bitmap will distort the grid. Using WorldUnits and choosing appropriate fonts/sizes is the best solution we have found.


AD Administrator Syncfusion Team March 14, 2005 08:09 AM UTC

I have given the sample ..if i am Setting the font unit to Graphicsunit.world the font size and face set for the cells doesnt reflect in the grid. the sample code is as follows using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WindowsApplication1 { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private Syncfusion.Windows.Forms.Grid.GridControl gridControl1; /// /// 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 // gridControl1.RowCount = 2; gridControl1.ColCount = 2; } /// /// 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.button1 = new System.Windows.Forms.Button(); this.gridControl1 = new Syncfusion.Windows.Forms.Grid.GridControl(); ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(576, 376); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(88, 32); this.button1.TabIndex = 0; this.button1.Text = "Print Preview"; this.button1.Click += new System.EventHandler(this.button1_Click); // // gridControl1 // this.gridControl1.Location = new System.Drawing.Point(40, 24); this.gridControl1.Name = "gridControl1"; this.gridControl1.Size = new System.Drawing.Size(736, 352); this.gridControl1.TabIndex = 1; this.gridControl1.Text = "gridControl1"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(880, 429); this.Controls.Add(this.gridControl1); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit(); this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { this.gridControl1.BaseStylesMap["Standard"].StyleInfo.Font.Unit = GraphicsUnit.World; gridControl1[1,1].CellValue = "This is single line"; gridControl1[1,2].CellValue = "This is going to be (This text is to increase the width)a multiple line in the grid "+System.Environment.NewLine+ "This is the second line in the cell"+System.Environment.NewLine+ "Check this line is printed correctly"; gridControl1.ColWidths.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Col(2),Syncfu sion.Windows.Forms.Grid.GridResizeToFitOptions.IncludeHeaders); gridControl1.RowHeights.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Row(1),Syncf usion.Windows.Forms.Grid.GridResizeToFitOptions.IncludeHeaders); } private System.Drawing.Printing.PrintDocument GetDoc() { Syncfusion.Windows.Forms.Grid.GridPrintDocument doc = new Syncfusion.Windows.Forms.Grid.GridPrintDocument(this.gridControl1, true); return doc; } private void button1_Click(object sender, System.EventArgs e) { System.Drawing.Printing.PrintDocument printDoc = GetDoc(); System.Windows.Forms.PrintPreviewDialog pdlg = new PrintPreviewDialog(); pdlg.Document = printDoc; pdlg.ShowDialog(); } } }

Loader.
Up arrow icon