I need to be able to scroll a RichTextBox to the bottom, even when I am not appending text. I know I can append text, and then use that to set the selection start. However I want to ensure it is at the bottom for visual reasons, so I am not adding any text.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Code should be written in the rich text box's TextChanged event like :
In WPF you can use ScrollToEnd:
You could try setting the SelectionStart property to the length of the text and then call the ScrollToCaret method.
The
RichTextBox
will stay scrolled to the end if it has focus and you useAppendText
to add the information. If you setHideSelection
to false it will keep its selection when it loses focus and stay auto-scrolled.I designed a Log Viewer GUI that used the method below. It used up to a full core keeping up. Getting rid of this code and setting
HideSelection
to false got the CPU usage down to 1-2%.There is no need for:
This does the trick: