The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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
ADAdministrator Syncfusion Team September 28, 2005 11:07 PM UTC
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