We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Resize Textbox to show all text

directxBOB asked
Medium Priority
Last Modified: 2012-05-06
I currently have a textbox which is populated from the database, I was wondering how I would go about resizing the textbox to fit this text. Now I've seen it done like:

Dim mySize As  New System.Drawing.SizeF
Dim myFont As New System.Drawing.Font  (Me.TextBox1.Font.FontFamily, Me.TextBox1.Font.Size)
mySize = e.Graphics.MeasureString("This is a test", myFont)
Me.TextBox1.Width = CType(Math.Round(mySize.Width, 0), Integer)

Open in new window

Watch Question

Me.TextBox1.Width = Unit.Pixel(8 * TextBox1.Text.Length)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Try jquery and auto grow plug-in. Please check followin link. Cool coding.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.