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. Image for the cookie policy date

Font issue - Courier New

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

5 Replies

ST stanleyj Syncfusion Team December 28, 2005 01:20 PM UTC

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


AD Administrator Syncfusion Team December 29, 2005 04:10 AM UTC

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


ST stanleyj Syncfusion Team December 29, 2005 04:57 AM UTC

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


AD Administrator Syncfusion Team December 29, 2005 07:32 AM UTC

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; } }


ST stanleyj Syncfusion Team December 30, 2005 10:21 AM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon