Unplanned
Last Updated: 15 Jul 2026 07:53 by Martin Ivanov
Martin Ivanov
Created on: 15 Jul 2026 07:53
Category: RichTextEditor
Type: Bug Report
0
RichTextEditor: Scrollbar offset is not reset when you resize the control until the scrollbars disappear

The vertical and horizontal scrollbar positions get cached during scrolling. If you scroll around and then resize the RadRichTextEditor so that the scrollbars are no longer needed and then you resize the editor again to show the scrollbars, the cached position is used, instead of resetting it to 0,0. 

This reproduces when the LayoutMode of the editor i set to FlowNoWrap.

To work this around, reset the scrollbars' Value to 0 on SizeChanged.

private void RadRichTextEditor1_SizeChanged(object sender, EventArgs e)
{
    Normalize(radRichTextEditor1.RichTextBoxElement.VerticalScrollBar);
    Normalize(radRichTextEditor1.RichTextBoxElement.HorizontalScrollBar);
}

private static void Normalize(RadScrollBarElement sb)
{
    int maxUser = Math.Max(sb.Minimum, sb.Maximum - sb.LargeChange + 1);

    if (sb.Visibility != ElementVisibility.Visible)
    {
        sb.Value = sb.Minimum;   
        return;
    }

    if (sb.Value > maxUser)
    {
        sb.Value = maxUser;
    }
}

0 comments