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 rendering in Grid control

Thread ID:





59638 Apr 18,2007 04:54 PM Apr 19,2007 03:04 PM Windows Forms 4
Tags: GridControl
Asked On April 18, 2007 04:54 PM

Hopefully you can shed some light on the rendering of fonts in the Grid control.

We are using the Grid control to display information originally authored in MS Excel (currently Office 2002). The expectation (by our users) is that the information displayed in the grid will be identical to how it lays out in Excel.

In this example, we are using the Tahoma font (sizes 8pt and 10pt). When we pull the information from the spreadsheet and display it in the grid (setting the cell's Font.Facename and Font.Size properties) the text actually displays slightly wider than it does in Excel. This ultimately causes text to get cut off in some cases.

I have done some research and have tried to set the Font.Unit property to GraphicsUnit.Display but all this does is display red cells containing the work "Exception".

If it makes a difference, we are using CoveredRanges to merge columns for this text.

Please let me know if I am missing something in what I am doing. If required, I can send a quick example.

Tom Murphy

haneefm [Syncfusion]
Replied On April 18, 2007 05:54 PM


Please try to provide us some more information on this issue. I tried to reproduce the issue, but couldn't. kindly provide us a small sample to reproduce the issue or modify any of our browser sample accordingly. This will help us to analyse the issue further.

Best regards,

Replied On April 19, 2007 10:21 AM


Thanks for your quick response.

I have attached a ZIP file that contains a BMP that demonstrates what I am seeing. You will notice that columns A and B are set to the same width (demonstrated by the thin red lines). But as you can see, the text in the form (Form1)displays much wider than that in Excel (the top cells) as demonstrated by the thicker red line.

I have also included the quick test app that I used to output Form1 in the image. In both cases cells A1 and B1 are merged and using a Tahoma 10 bold font.

Please let me know if there is any additional information that you require.

Thanks again for your response.
Tom Murphy


haneefm [Syncfusion]
Replied On April 19, 2007 01:58 PM

Hi Tom,

This can be resolved by handling the DrawCellDisplayText event and call the DrawText method to draw the text in a grid cell. Here is a code snippet

private void gridControl1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style,e.ClipBounds, false);

Best regards,

Replied On April 19, 2007 03:04 PM


Thanks for the quick resolution. That seemed to do the trick.

The DrawText only seemed to required 5 paramters and the final "false" in your example was not needed but once that was removed things compiled and ran great.

Tom Murphy


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.