Hello there,
I am using the UltraTextEditor to display log messages. I can not figure out, how to scroll to the end after I added a new line. What am I missing?
Any help would be appreciated,
Dennis
Oh, okay. So that seems like a good way to do it. :)
ScrollToCaret is documented as needing the AlwaysInEditMode property set to true.
I am using the UltraTextEditor in the same way as the original poster, ie in multiline mode to display progress of a task. With AlwaysInEditMode set to true, ScrollToCaret works fine and scrolls to the last line, but without this property, ScrollToCaret seems to be completely ignored.
The control is set as follows:
progressTextEditor.AlwaysInEditMode = TrueprogressTextEditor.Multiline = TrueprogressTextEditor.ReadOnly = TrueprogressTextEditor.Scrollbars = System.Windows.Forms.ScrollBars.BothprogressTextEditor.TabStop = FalseprogressTextEditor.WordWrap = False
Each time a new line is added, I do:
progressTextEditor.SelectionStart = progressTextEditor.TextLengthprogressTextEditor.ScrollToCaret()
Are you suggesting this as a solution? Or as a way to duplicate the problem?
This code seems like it should result in an error, since you cannot set the SelectionStart when the control is not in edit mode.
Try this:
_ultraTextEditor.Editor.ExitEditMode(
true, true);
_ultraTextEditor.SelectionStart = _ultraTextEditor.Text.Length;
_ultraTextEditor.ScrollToCaret();
Hi Roy,
I'm not sure I understand what you are trying to do here. But the error message is pretty clear. The control has to be in edit mode for SelectionStart or SelectionLength to be changed - so that include calling the Select method.
Make sure the control has focus and before you call this code.