Highlighting and scrolling down via down key

2 posts, 0 answers
  1. Ken
    Ken avatar
    1 posts
    Member since:
    Aug 2011

    Posted 04 Apr 2012 Link to this post

    There appears to be an issue with the RichTextBox Editor when you highlight text and continue highlighting using the downkey. The textbox does not scroll down with your keypresses as it does when you are not highlighting. It will stay at the top and you can no longer track your highlighting below the visible area.

    Thanks for continued excellence in support.
  2. Svett
    Svett avatar
    728 posts

    Posted 09 Apr 2012 Link to this post

    Hello Ken,

    I managed to reproduce the issue. I added it to our public issue tracking system and it will be addressed in one of the next releases. Meanwhile, you can use the following workaround:

    public class MyDocumentNavigator : DocumentNavigator
        public MyDocumentNavigator(DocumentView view)
            : base(view)
        public override bool ScrollToCaret()
            IEditorCaret caret = this.DocumentView.Caret;
            RectangleF viewportBounds = this.DocumentView.ControlBoundingRectangle;
            if (caret == null || viewportBounds.IsEmpty)
                return false;
            RectangleF caretBounds = new RectangleF(caret.Position, new SizeF(caret.Width, caret.Height));
            float deltaX = 0;
            float deltaY = 0;
            if (caretBounds.Right > viewportBounds.Right)
                deltaX = caretBounds.Right - viewportBounds.Width / 2;
            else if (caretBounds.Left < viewportBounds.Left)
                deltaX = caretBounds.Left - viewportBounds.Width / 2;
            if (caretBounds.Top < viewportBounds.Top)
                deltaY = caretBounds.Top - viewportBounds.Top;
            else if (caretBounds.Bottom > viewportBounds.Bottom)
                deltaY = caretBounds.Bottom - viewportBounds.Bottom;
            IEditorScrollBar vScrollBar = this.DocumentView.Scroller.VScrollBar;
            IEditorScrollBar hScrollBar = this.DocumentView.Scroller.HScrollBar;
            hScrollBar.Value = DocumentScroller.ClampScrollBarValue(hScrollBar, hScrollBar.Value + (int)deltaX);
            vScrollBar.Value = DocumentScroller.ClampScrollBarValue(vScrollBar, vScrollBar.Value + (int)deltaY);
            return true;

    You should replace the default navigator by using the following code snippet:
    this.richTextBox.DocumentView.Navigator = new MyDocumentNavigator(this.richTextBox.DocumentView);

    I updated your Telerik points.

    Kind regards,
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top