Hi
Is it possible to get a richtextbox to autoscroll vertical.
I would like the box to autoscroll when new text is added.
Richtextbox Auto Scroll
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Richtextbox Auto Scroll
FYI, I moved this post to the GUI forums.
I guess it depends on where you are inserting the text but you can use the ScrollToCaret method:
I guess it depends on where you are inserting the text but you can use the ScrollToCaret method:
PowerShell Code
Double-click the code block to select all.#Scroll to the end of the textbox $richtextbox1.SelectionStart = $richtextbox1.TextLength; $richtextbox1.ScrollToCaret()David
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Richtextbox Auto Scroll
Hi David
I have attached an example of what I am trying to do.
eks.
Button1: add text to richtextbox1, and auto scroll to end
Button2: append text to richtextbox1, and auto scroll to end
I can not get this to work.
Can you see what I am doing wrong
I have attached an example of what I am trying to do.
eks.
Button1: add text to richtextbox1, and auto scroll to end
Button2: append text to richtextbox1, and auto scroll to end
I can not get this to work.
Can you see what I am doing wrong
- Attachments
-
- Test.zip
- (3.09 KiB) Downloaded 720 times
Re: Richtextbox Auto Scroll
You never should declare a function in a script block if you plan to call it from outside the script block. This works in PowerShell V2 but will fail in V3.
Other than the function declaration the code worked for me. Note when the textbox is not in focus you can't see the caret. You can focus the control when the text changes:
Other than the function declaration the code worked for me. Note when the textbox is not in focus you can't see the caret. You can focus the control when the text changes:
PowerShell Code
Double-click the code block to select all.$richtextbox1_TextChanged={ $richtextbox1.SelectionStart = $richtextbox1.TextLength; $richtextbox1.ScrollToCaret() $richtextbox1.Focus() }Also I recommend using the AppendText method:
PowerShell Code
Double-click the code block to select all.function outTextBox1($textOut) { $richtextbox1.AppendText($textOut) }David
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.