Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 691
  • Last Modified:

ScrollToCaret() or scroll text in text box

Hello,

I'm working an example application the displays folder activity in a text box. How can I have to text scroll as its being entered?
I think something like ScrollToCaret() is what I may need, but not sure how to add it.

Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
        If e.ChangeType = WatcherChangeTypes.Changed Then
            txt_folderactivity.Text &= "File " & e.FullPath & " has been modified" & vbCrLf
        End If
        If e.ChangeType = WatcherChangeTypes.Created Then
            txt_folderactivity.Text &= "File " & e.FullPath & " has been created" & vbCrLf
        End If
        If e.ChangeType = WatcherChangeTypes.Deleted Then
            txt_folderactivity.Text &= "File " & e.FullPath & " has been deleted" & vbCrLf
        End If
    End Sub
0
JRockFL
Asked:
JRockFL
  • 2
  • 2
1 Solution
 
iboutchkineCommented:
txt_folderactivity.ScrollToCaret()
0
 
JRockFLAuthor Commented:
I had tried something like this, but its not working.

 Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
        If e.ChangeType = WatcherChangeTypes.Changed Then
            txt_folderactivity.Text &= "File " & e.FullPath & " has been modified" & vbCrLf
            txt_folderactivity.ScrollToCaret()
            txt_folderactivity.Refresh()
        End If
        If e.ChangeType = WatcherChangeTypes.Created Then
            txt_folderactivity.Text &= "File " & e.FullPath & " has been created" & vbCrLf
            txt_folderactivity.ScrollToCaret()
            txt_folderactivity.Refresh()
        End If
        If e.ChangeType = WatcherChangeTypes.Deleted Then
            txt_folderactivity.Text &= "File " & e.FullPath & " has been deleted" & vbCrLf
            txt_folderactivity.ScrollToCaret()
            txt_folderactivity.Refresh()
        End If
    End Sub
0
 
iboutchkineCommented:
it must work. Make sure that caret is at the end of the text

txt_folderactivity.SelectAll()
txt_folderactivity.SelectionStart = TextBox1.SelectionLength
txt_folderactivity.ScrollToCaret()

that must position th caret at the bottom of the textbox
0
 
JRockFLAuthor Commented:
Now that worked, thank you!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now