DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Location
    Jacksonville, FL
    Posts
    17

    Question Creating Scrollable Text Boxes

    Another rookie question...

    I would like to create a text box that allows you to continually append text, and view what you wish via a vertical scroll bar. The best analogy I have is an Instant Messaging window, a la AIM or ICQ.

    I'm assuming I would set txtBoxName.ScrollBars to 2-Vertical, and txtBoxName.MultiLine to True.

    How do you add text to the text box without overwriting the contents? For instance, if you have a statement txtBoxName.Text = "First Line", how do you avoid clobbering it with another statement txtBoxname.Text = "Second Line"? The only thing I can think of is to embed a return character at the end of each line of text. Is there an easy (or at least elegant!) way to do this?

    Thanks much for your help!
    -- Miles

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Instead of assigning new text to the .Text property, assign it to the .SelText property. You may include vbCrLf for line breaks as desired.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Apr 2005
    Location
    Jacksonville, FL
    Posts
    17
    Thanks Phil! Your suggestion works great. I hadn't hear of .SelText -- I'll look that one up.

    Thanks again!
    -- Miles

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    before using SelText, you should set the insertion point at the end of the text, otherwise it is inserted wherever the pointer is (in case someone click with the cursor inside the text):

    .SelStart = len(.Text)
    .SelText = newstring & vbcrlf

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Apr 2005
    Location
    Jacksonville, FL
    Posts
    17
    Good tip. Thanks Marco!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links