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.

Font issue - Courier New

Thread ID:

Created:

Updated:

Platform:

Replies:

39100 Dec 27,2005 07:28 AM Dec 30,2005 05:21 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 27, 2005 07:28 AM

Hi, Essential grid - v 2.0.5.1 .NET Framework - v 1.1 I have populated the GridControl with some values. When I trying to edit those values in GridControl, the text enlarges only if i use the font as "Courier New", Other fonts do not. How do I prevent this? Thanks in advance, Dhans

stanleyj [Syncfusion]
Replied On December 28, 2005 08:20 AM

Hi Dhans, This seems to be the side effects of GDI+ drawing, switching to GDI drawing, the text will look the same while editing with little Offset. this.gridControl1.DrawCellDisplayText += new GridDrawCellDisplayTextEventHandler(gridControl1_DrawCellDisplayText); private void gridControl1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e) { Rectangle r = e.TextRectangle; r.Offset(2, 0); GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, r, e.Style); e.Cancel = true; } Best regards, Stanley

Administrator [Syncfusion]
Replied On December 28, 2005 11:10 PM

Hi Stanley, Thanks for your reply. But this don''t work for me. Still the text length increases while i am trying to edit on a particular cell. Regards, Dhans

stanleyj [Syncfusion]
Replied On December 28, 2005 11:57 PM

Hi Dhans, I could not see any enlargement with short and long text. What is the text and the column width of that cell? Also try modifying the offset to see if that helps. Best regards, Stanley

Administrator [Syncfusion]
Replied On December 29, 2005 02:32 AM

Here is the code try to run this code, you could find the diff in displaying the text while editing the cell public class Form1 : System.Windows.Forms.Form { 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(); for(int col=0; col <= gridControl1.ColCount; col++) { this.gridControl1[1, col].Text = "0123456789ABCEDF"; gridControl1.ColWidths.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Col(col), Syncfusion.Windows.Forms.Grid.GridResizeToFitOptions.IncludeHeaders); } this.gridControl1.DrawCellDisplayText += new Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventHandler(gridControl1_DrawCellDisplayText); Init(); } /// /// 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() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1)); Syncfusion.Windows.Forms.Grid.GridStyleInfo gridStyleInfo1 = new Syncfusion.Windows.Forms.Grid.GridStyleInfo(); this.gridControl1 = new Syncfusion.Windows.Forms.Grid.GridControl(); ((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit(); this.SuspendLayout(); // // gridControl1 // this.gridControl1.Data = ((Syncfusion.Windows.Forms.Grid.GridData)(resources.GetObject("gridControl1.Data"))); this.gridControl1.Font = new System.Drawing.Font("Courier New", 8.25F); this.gridControl1.Location = new System.Drawing.Point(1, 1); this.gridControl1.Name = "gridControl1"; this.gridControl1.NumberedColHeaders = false; this.gridControl1.NumberedRowHeaders = false; this.gridControl1.Properties.ColHeaders = false; this.gridControl1.Properties.RowHeaders = false; this.gridControl1.Size = new System.Drawing.Size(871, 455); this.gridControl1.TabIndex = 0; gridStyleInfo1.Font.Bold = false; gridStyleInfo1.Font.Facename = "Courier New"; gridStyleInfo1.Font.Italic = false; gridStyleInfo1.Font.Size = 8.25F; gridStyleInfo1.Font.Strikeout = false; gridStyleInfo1.Font.Underline = false; gridStyleInfo1.Font.Unit = System.Drawing.GraphicsUnit.Point; this.gridControl1.TableStyle = gridStyleInfo1; this.gridControl1.Text = "gridControl1"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(880, 461); this.Controls.Add(this.gridControl1); this.Name = "Form1"; this.Text = "Form1"; ((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()); } void Init() { string test = "0123ABCD4567EF"; for(int row=2; row <= gridControl1.RowCount; row++) { for(int col=0; col <= gridControl1.ColCount; col++) { this.gridControl1[row, col].Text = test + row + col; } } } private void gridControl1_DrawCellDisplayText(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs e) { Rectangle rect = e.TextRectangle; rect.Offset(2,0); Syncfusion.Windows.Forms.Grid.GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, rect, e.Style); e.Cancel = true; } }

stanleyj [Syncfusion]
Replied On December 30, 2005 05:21 AM

Hi Dhans, I see some odd behavior in 2.0.5.1 but in versions after 3.0 the suggested offset in DrawCellDisplayText is fine. You can also try our latest version 4.1, for which beta is available. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=39029 Best regards, Stanley

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.

;