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.

number of characters vs. number of pixels

Thread ID:

Created:

Updated:

Platform:

Replies:

35377 Sep 28,2005 03:03 PM Sep 28,2005 07:07 PM Windows Forms 1
loading
Tags: GridControl
Nancy Jan
Asked On September 28, 2005 03:03 PM

Hi, I use the latest version of GGC. The GridColumnDescriptor.Width returns a value represents number of pixels. Instead of pixels, how to get the value in number of characters? Thanks, NJ

Administrator [Syncfusion]
Replied On September 28, 2005 07:07 PM

Hi Nj, there is no precise way to convert from pixels to characters unless you do a use a fixed font and not a propertional font. An estimate can calculated with Graphics g; int charWidth = (int) g.MeasureString("Abc", font).Width/3; and then divide the column.width with charWith. You can also determine the maximum length of characters found in the column using the GridTable.GetColumnMaxLength(columnDescriptor) method. If you do not explicitly set a column.Width then the grid will actually automatically size the column by calling GridTable.GetColumnMaxLength and then multiply this with the same charWidth used above. This is done within the GridTable.GetPreferredColumnWidth(columnDescriptor) method. Stefan >Hi, > > I use the latest version of GGC. The GridColumnDescriptor.Width returns a value represents number of pixels. Instead of pixels, how to get the value in number of characters? > >Thanks, >NJ

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.

;