1

I have a RichTextBox and it scrolls with every AppendText, but it shall only scroll if the scrollbar is at bottom. I would like for example to easily select and copy something from the middle of the richtextbox while text is appended to the RichTextBox. Tried many solutions, but nothing really worked correct. Is this even possible?

1 Answer 1

0

It depends how you are Appending, but you can tell it to focus back to where the selection (or just cursor) is after appending.

eg (untested, assuming WinForms):

int selStart = rtb.SelectionStart int selLength = rtb.SelectionLength rtb.AppendText("test") rtb.SelectionStart = selStart rtb.SelectionLength = selLength 

That will always push the selection back to where it was before the append - but won't scroll down if it was at the bottom previously. To me, that seems like expected behaviour.

Sign up to request clarification or add additional context in comments.

5 Comments

I tried that, but this solution did many mistakes. e.g. -You can't scroll, if you have something selected. -If you haven't selected anything and click at the bottom of the text the cusor goes up until it reaches the top. Now if more text is appended, it is not visible until you scroll again.
I would say the behavior of the skype textbox is the textbox behavior i need.
then you need to get the position of the scrollbar itself. Look into Scrollviewers.
It seems that scrollviewers are only available for WPF. I'm bound to WinForms, because i use KryptonForms.
ok, well I'll leave it to others more knowledgeable to try and help then!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.