S
Scott M.
This is an ASP.NET application? I wouldn't do it the way you are
attempting. Instead, I would determine the size you would like it to be
(based on characters in the box) and then add a CSS attribute to the tag
output to set its width.
tbText.attributes.add("style", "width:" & desiredWith)
No need to mess with the System.Drawing namespace (or even have a reference
to it).
textbox needs to resize, so I can't explicitely give the textbox a size in
pixels. Any ideas?
attempting. Instead, I would determine the size you would like it to be
(based on characters in the box) and then add a CSS attribute to the tag
output to set its width.
tbText.attributes.add("style", "width:" & desiredWith)
No need to mess with the System.Drawing namespace (or even have a reference
to it).
resize the listbox based on the text in it. So far I have:Greg said:How can I find out what the width of a textbox is in pixels? I want to
in the HTML), not hte number of pixels. If the window resizes, then the//resize listbox
Font newFont = new Font("Courier New", 10);
newBitmap = new Bitmap(1,1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
g = Graphics.FromImage(newBitmap);
SizeF stringSize = g.MeasureString(tbText.Text, newFont);
int nWidth = (int)stringSize.Width;
int nHeight = (int)stringSize.Height;
int textSize = nHeight * (nWidth /(int)tbText.Width);
The problem is that tbText.Width returns "95%" (since that's what i have
textbox needs to resize, so I can't explicitely give the textbox a size in
pixels. Any ideas?