Currently, the scrollbars width is calculated only according to SystemInformation.VerticalScrollBarWidth.
Workaround:
class MyRTE : RadRichTextEditor
{
protected override void CreateChildItems(RadElement parent)
{
var rte = new MyRTEElement();
typeof(RadRichTextEditor).GetField("richTextBox", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this, rte);
parent.Children.Add(rte);
}
}
public class MyRTEElement : RadRichTextBox
{
protected override SizeF ArrangeOverride(SizeF finalSize)
{
base.ArrangeOverride(finalSize);
System.Drawing.RectangleF finalRect = new System.Drawing.RectangleF(System.Drawing.PointF.Empty, finalSize);
System.Drawing.RectangleF clientRect = finalRect;
System.Drawing.RectangleF horizontalScrollRect = System.Drawing.RectangleF.Empty;
System.Drawing.RectangleF verticalScrollRect = System.Drawing.RectangleF.Empty;
System.Drawing.RectangleF presenterArea = clientRect;
if (this.VerticalScrollBar.Visibility != Telerik.WinControls.ElementVisibility.Collapsed)
{
verticalScrollRect = new System.Drawing.RectangleF(
new System.Drawing.PointF(finalRect.Right - this.VerticalScrollBar.Size.Width, finalRect.Top),
new System.Drawing.SizeF(this.VerticalScrollBar.Size.Width, finalRect.Height));
}
if (this.HorizontalScrollBar.Visibility != Telerik.WinControls.ElementVisibility.Collapsed)
{
horizontalScrollRect = new System.Drawing.RectangleF(
new System.Drawing.PointF(finalRect.Left, finalRect.Bottom - this.HorizontalScrollBar.Size.Height),
new System.Drawing.SizeF(finalRect.Width, this.HorizontalScrollBar.Size.Height));
if (this.VerticalScrollBar.Visibility != Telerik.WinControls.ElementVisibility.Collapsed)
{
horizontalScrollRect.Width -= this.VerticalScrollBar.Size.Width;
verticalScrollRect.Height -= this.HorizontalScrollBar.Size.Height;
}
}
presenterArea.Width -= verticalScrollRect.Width;
presenterArea.Height -= horizontalScrollRect.Height;
if (this.RightToLeft)
{
horizontalScrollRect = Telerik.WinControls.Layouts.LayoutUtils.RTLTranslateNonRelative(horizontalScrollRect, clientRect);
verticalScrollRect = Telerik.WinControls.Layouts.LayoutUtils.RTLTranslateNonRelative(verticalScrollRect, clientRect);
presenterArea = Telerik.WinControls.Layouts.LayoutUtils.RTLTranslateNonRelative(presenterArea, clientRect);
}
this.VerticalScrollBar.Arrange(verticalScrollRect);
this.HorizontalScrollBar.Arrange(horizontalScrollRect);
var contentPresenter = typeof(RadRichTextBox).GetField("contentPresenter", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this) as ContentControl;
contentPresenter.Arrange(presenterArea);
return finalSize;
}
protected override SizeF MeasureOverride(SizeF availableSize)
{
base.MeasureOverride(availableSize);
System.Drawing.SizeF horizontalScrollSize = System.Drawing.SizeF.Empty;
System.Drawing.SizeF verticalScrollSize = System.Drawing.SizeF.Empty;
System.Drawing.SizeF presenterSize = availableSize;
if (this.VerticalScrollBar.Visibility != Telerik.WinControls.ElementVisibility.Collapsed)
{
verticalScrollSize = new System.Drawing.SizeF(this.VerticalScrollBar.Size.Width, availableSize.Height);
}
if (this.HorizontalScrollBar.Visibility != Telerik.WinControls.ElementVisibility.Collapsed)
{
horizontalScrollSize = new System.Drawing.SizeF(availableSize.Width, this.HorizontalScrollBar.Size.Height);
}
presenterSize.Width -= verticalScrollSize.Width;
presenterSize.Height -= horizontalScrollSize.Height;
//presenterSize = base.GetClientRectangle(presenterSize).Size;
this.VerticalScrollBar.Measure(verticalScrollSize);
this.HorizontalScrollBar.Measure(horizontalScrollSize);
var contentPresenter = typeof(RadRichTextBox).GetField("contentPresenter", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this) as ContentControl;
contentPresenter.Measure(presenterSize);
return availableSize;
}
}