Solved

Multiline Textbox text problem

Posted on 2004-08-17
9
358 Views
Last Modified: 2012-05-05
Hi,

I am using a multiline textbox, but when the text goes beyond the boudries (vertically) I have to scroll to see the newest text.  For example:

My textbox is 5 lines vertically.  I have a button that adds an incrementing integer to the textbox on a new line at each click.  If I click the button 10 times, I will only see 1
2
3
4
5
then I have to scroll down to see the remaining number.  Is there a way to automatically scroll so that the latest piece of text is alway svisible, and the top text disapears above the boundries...?

Thanks guys...
0
Comment
Question by:jakekula
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11827689
How are you adding the text to the textbox?  This works for me:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Static lineNumber As Integer
        lineNumber = lineNumber + 1
        TextBox1.AppendText(lineNumber & vbCrLf)
    End Sub

End Class

Regards,

Idle_Mind
0
 

Author Comment

by:jakekula
ID: 11827786
I am using the following code:

TextBox1.Text &= vbCrLf & "some text"

0
 
LVL 14

Expert Comment

by:ptakja
ID: 11829683
The try what Idle_Mind suggested...  

TextBox1.AppendText("Some Text" & Environment.Newline)
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:jakekula
ID: 11836238
Thanks guys, the problem is that I'm using VB.Net Compact Framework as I'm developing for a Pocket PC.  The AppendText() function is not available.
0
 
LVL 3

Expert Comment

by:Scoobyed
ID: 11838614
this is available on compact framework textbox

Me.txtMessage.ScrollToCaret()
0
 

Author Comment

by:jakekula
ID: 11838631
Thanks Scoobyed,  so how would I implement it into my code...?

Currently I am using

Textbox1.text &= vbCrLf & "some"

Textbox1.text &= vbCrLf & "sort"

Textbox1.text &= vbCrLf & "of"

Textbox1.text &= vbCrLf & "message"




0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 11840561
Like this:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        cfAppendText(TextBox1, "some")
        cfAppendText(TextBox1, "sort")
        cfAppendText(TextBox1, "of")
        cfAppendText(TextBox1, "message")
    End Sub

    Private Sub cfAppendText(ByVal tb As TextBox, ByVal msg As String)
        tb.Text &= vbCrLf & msg
        tb.SelectionStart = tb.Text.Length
        tb.SelectionLength = 0
        tb.ScrollToCaret()
    End Sub
0
 
LVL 3

Expert Comment

by:Scoobyed
ID: 11850537
should I not get an assist for that?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11851025
I agree Scoobyed.

jakekula,

Please consider posting a request in Community Support to change the point allocations.
http://www.experts-exchange.com/Community_Support/

Idle_Mind
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now