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.

print multiple lines of text in a cell

Thread ID:

Created:

Updated:

Platform:

Replies:

25883 Mar 9,2005 02:21 AM Mar 11,2005 04:56 AM Windows Forms 12
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 9, 2005 02:21 AM

In a cell i have multiple lines of text displayed. But when i print this grid, only single line in the cell is printed..the remaining lines are truncated. (But when i copy the grid values to the print grid, the complete text is copied.) How do i solve this problem.

Administrator [Syncfusion]
Replied On March 9, 2005 03:49 AM

>>when i copy the grid values to the print grid How are you doing this? What is the print grid? If you just directly print the original grid, does it print properly? In this print grid, is style.AllowWrap set for these cells that you want to display multiple lines in? Aslo, is the rowheights in the print grid being set to match the row heights in the original grid?

Administrator [Syncfusion]
Replied On March 9, 2005 03:57 AM

I copied the rowheights and colwidths from the original grid to print grid. (i copy the original grid values to a new grid called print grid). i didnt explicitly set style.allowwrap for the cells that have multiple lines in the print grid.. Do i need to set this property in the printgrid? >In this print grid, is style.AllowWrap set for these cells that you want to display multiple lines in? Aslo, is the rowheights in the print grid being set to match the row heights in the original grid?

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

I am sorry. the property name is style.WrapText, not style.AllowWrap. If copy ''styles'' instead of ''values'', then the style.WrapText setting will be copied in addition to the values. But if you do not copy styles, then you will need to make sure this style is set in the grid you are printing, otherwise the text will not wrap.

Administrator [Syncfusion]
Replied On March 9, 2005 08:06 AM

I set the property style.wraptext to true in the printgrid. Also i have copied the rowheights and column widths to the print grid from original grid. I am getting multiple lines but the last line is truncated.

Administrator [Syncfusion]
Replied On March 9, 2005 08:24 AM

You might try calling grid.RowHeights.ResizeToFit on your print grid to see if this avoids this problem. Another thing to try is to set this.grid.BaseStylesMap["Standard"].StyleInfo.Font.Unit = GraphicsUnit.World; on both grids to see it that avoids this problem. If you can upload a sample project showing the problem, or tell us how to see the problem in one of our samples, we can try to debug it here.

Administrator [Syncfusion]
Replied On March 10, 2005 01:37 AM

The code i used to copy the original grid to printgrid is as follows for( int row=0; row<=grid.RowCount; row++) { printGrid.RowHeights[row]=grid.RowHeights[row]; for( int col=0; col<=grid.ColCount; col++) { // Copy the visible features of the cell to the print cell GridStyleInfo printCell = printGrid[row,col]; GridStyleInfo cell = grid[row,col]; printCell.Text = cell.Text; printCell.BackColor = cell.BackColor; printCell.CellType = cell.CellType; printCell.TextColor = cell.TextColor; printCell.Font = cell.Font; printCell.HorizontalAlignment = cell.HorizontalAlignment; printCell.VerticalAlignment = cell.VerticalAlignment; printCell.Description = cell.Description; printCell.ImageList = cell.ImageList; printCell.ImageIndex = cell.ImageIndex; } } But still i didnt get the last line in the cell that has multiple lines.(In original grid,i had three lines in a cell. In the printgrid , i got three lines for that cell.But the text is broken..in such a way that the two lines in the original cell has accounted for three lines in the print grid. ) I copied the colwidth also..but i didnt get it correctly.

Administrator [Syncfusion]
Replied On March 10, 2005 03:49 AM

Did you try using the GraphicsUnit.World on both grids to see it that avoids this problem as was previously suggested? Again, if you can upload a sample project showing the problem, or tell us how to see the problem in one of our samples, we can try to debug it here.

Administrator [Syncfusion]
Replied On March 10, 2005 10:37 PM

I have attached the sample. Run the sample. Click the Print Preview Button You will find that the last line is missing in the print preview and also if its printed. Thanks clay

Administrator [Syncfusion]
Replied On March 10, 2005 10:45 PM

I have attached the sample. Run the sample. Click the Print Preview Button You will find that the last line is missing in the print preview and also if its printed. Thanks clay

Administrator [Syncfusion]
Replied On March 10, 2005 11:20 PM

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 u 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. Thanks Clay

Administrator [Syncfusion]
Replied On March 11, 2005 04:07 AM

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

Administrator [Syncfusion]
Replied On March 11, 2005 04:56 AM

Suppose 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

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.

;