Last post Nov 17, 2010 04:50 AM by Heisa
Nov 17, 2010 04:50 AM|Heisa|LINK
I am trying to make a textbox re-size to fit the text provided. I found a solution in C#:
Graphics g = Graphics.FromHwnd(textBox1.Handle);
SizeF f = g.MeasureString("String to fit", textBox1.Font);
textBox1.Width = (int)(f.Width);
// textBox1.Height = (int)(f.Height); // if required...
textBox1.Text = "String to fit";
I'm using VB.net and the Textbox1.handle is not present in VB.net. The project is running on .NET Framework 1.1
Is there another way to get the handle of the TextBox?
Thanks in advance!