Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleSize a TextBox to fit its contents
KeywordsTextBox, size, fit, resize
CategoriesControls
 
Make sure the form's font matches the TextBox's (or use a hidden PictureBox control). Use the form's TextWidth and TextHeight methods to see how much room the text needs. Then size the TextBox accordingly, allowing a little extra room for the TextBox's borders.
 
' Make the TextBox fit its contents.
Private Sub FitTextBoxContents(ByVal txt As TextBox)
    Font = Text1.Font
    txt.Width = TextWidth(txt.Text) + 120
    txt.Height = TextHeight(txt.Text) + 120
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated