Solved

Multiline Textbox text problem

Posted on 2004-08-17
9
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 86

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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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 86

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 86

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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