S
Sangeeta
Hi,
I have a datagrid where columns are of some fixed pixel size. If any
column text increases the width of column, the plan is to truncate it
till its pixel width becomes less than the coloumn width.
Is there a way to find the size of a char in pixel given the font name
and size. I have tried using System.Drawing.Graphics object, but the
width attribute of the returned fSize object does not return value in
pixels. I am including the code in this mail, can anyone tell me if I
there is another approach or if I am doing this the wrong way.
Thanks,
Sangeeta
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Font ft= new Font("CourierThai", 14);
System.Drawing.Image img = System.Drawing.Image.FromFile
(MapPath
"Images/Deepa.jpg"));
System.Drawing.Graphics gh = System.Drawing.Graphics.FromImage(img);
gh.PageUnit = GraphicsUnit.Pixel;
Response.Write(gh.DpiX);
Response.Write(gh.MeasureString("Test", ft).Width);
Response.Write(ft.SizeInPoints);
}
I have a datagrid where columns are of some fixed pixel size. If any
column text increases the width of column, the plan is to truncate it
till its pixel width becomes less than the coloumn width.
Is there a way to find the size of a char in pixel given the font name
and size. I have tried using System.Drawing.Graphics object, but the
width attribute of the returned fSize object does not return value in
pixels. I am including the code in this mail, can anyone tell me if I
there is another approach or if I am doing this the wrong way.
Thanks,
Sangeeta
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Font ft= new Font("CourierThai", 14);
System.Drawing.Image img = System.Drawing.Image.FromFile
(MapPath
"Images/Deepa.jpg"));
System.Drawing.Graphics gh = System.Drawing.Graphics.FromImage(img);
gh.PageUnit = GraphicsUnit.Pixel;
Response.Write(gh.DpiX);
Response.Write(gh.MeasureString("Test", ft).Width);
Response.Write(ft.SizeInPoints);
}