To reproduce:
- Use the cut option in the context menu then dispose the rich text editor and collect the garbage.
Workaround:
Telerik.WinControls.RichTextEditor.UI.ContextMenu menu = textEditor.RichTextBoxElement.ContextMenu as Telerik.WinControls.RichTextEditor.UI.ContextMenu;
textEditor.RichTextBoxElement.ContextMenu = null;
RadDropDownMenu ddm = menu.GetType().GetField("radDropDownMenu", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(menu) as RadDropDownMenu;
Workaround: set the FormBorderStyle property to FixedSingle for the respective dialog. RadForm f = this.radRichTextEditor1.RichTextBoxElement.FontPropertiesDialog as RadForm; f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
To reproduce: use the following code snippet and refer to the attached screenshot. Cells' width should be identical in both of the cases. RadDocument document = new RadDocument(); Section section = new Section(); Table t = new Table(); t.Borders = new TableBorders(new Border(2, Telerik.WinForms.Documents.Model.BorderStyle.Single, Color.Black)); TableRow r1 = new TableRow(); TableCell cell = new TableCell(); Paragraph p = new Paragraph(); Span s = new Span(); s.Text = "Header"; cell.ColumnSpan = 3; p.Inlines.Add(s); cell.Blocks.Add(p); cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 100); r1.Cells.Add(cell); TableRow r2 = new TableRow(); TableCell cell11 = new TableCell(); Paragraph p11 = new Paragraph(); Span s11 = new Span(); s11.Text = "Cell1,1"; p11.Inlines.Add(s11); cell11.Blocks.Add(p11); cell11.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 40); TableCell cell12 = new TableCell(); Paragraph p12 = new Paragraph(); Span s12 = new Span(); s12.Text = "Cell1,2"; p12.Inlines.Add(s12); cell12.Blocks.Add(p12); cell12.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 10); TableCell cell13 = new TableCell(); Paragraph p13 = new Paragraph(); Span s13 = new Span(); s13.Text = "Cell1,3"; p13.Inlines.Add(s13); cell13.Blocks.Add(p13); cell13.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 50); r2.Cells.Add(cell11); r2.Cells.Add(cell12); r2.Cells.Add(cell13); t.Rows.Add(r1); t.Rows.Add(r2); section.Blocks.Add(t); document.Sections.Add(section); this.radRichTextEditor1.Document = document; Workaround: do not specify the PreferredWidth proeprty for cells with ColumnSpan>1
To reproduce: RadDocument document = new RadDocument(); Section section = new Section(); Paragraph p = new Paragraph(); Span span = new Span(); span.Text ="test" + Environment.NewLine + "test"; ReadOnlyRangeStart rangeStart = new ReadOnlyRangeStart(); ReadOnlyRangeEnd rangeEnd = new ReadOnlyRangeEnd(); rangeEnd.PairWithStart(rangeStart); p.Inlines.Add(rangeStart); p.Inlines.Add(span); p.Inlines.Add(rangeEnd); section.Blocks.Add(p); document.Sections.Add(section); this.radRichTextEditor1.Document = document; Workaround: add an empty span as last inline element in the paragraph: RadDocument document = new RadDocument(); Section section = new Section(); Paragraph p = new Paragraph(); Span span = new Span(); span.Text ="test" + Environment.NewLine + "test"; ReadOnlyRangeStart rangeStart = new ReadOnlyRangeStart(); ReadOnlyRangeEnd rangeEnd = new ReadOnlyRangeEnd(); rangeEnd.PairWithStart(rangeStart); p.Inlines.Add(rangeStart); p.Inlines.Add(span); p.Inlines.Add(rangeEnd); /////////////////////////////////////// Span emptySpan = new Span(); emptySpan.Text = " "; p.Inlines.Add(emptySpan); /////////////////////////////////////// section.Blocks.Add(p); document.Sections.Add(section); this.radRichTextEditor1.Document = document;
To reproduce:
- Set the ParagraphDefaultSpacingAfter to 1.
- Start the application and add a comment directly.
The issue exist when there is many comments as well. The comment balloons should have minimum size and should not overlap eachother.
Workaorund:
void radRichTextEditor1_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (e.Command is InsertCommentCommand)
{
int paragaphs = radRichTextEditor1.Document.Sections.First().Blocks.Count();
if (paragaphs <= 1)
{
radRichTextEditor1.InsertLineBreak();
}
}
}
When some commands are executed the RibbonUI is not updated.
For example:
private void radButton1_Click(object sender, EventArgs e)
{
ToggleCommentsCommand command = new ToggleCommentsCommand(radRichTextEditor1.RichTextBoxElement);
command.Execute();
}
Workaround:
var button = ribbonBar1.GetType().GetField("toggleButtonShowHideComments", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this.ribbonBar1) as RadToggleButtonElement;
button.ToggleState = (radRichTextEditor1.RichTextBoxElement.ShowComments == true) ? ToggleState.On : ToggleState.Off;
To reproduce:
- Add some comments and try to navigate through them.
- Try add or show/hide the comments while the cursor is in one of the comments.
Workaround:
Create a custom RichTextEditorRibbonBar
and override the following methods:
Public Class MyRichTextEditorRibbonBar
Inherits RichTextEditorRibbonBar
Protected Overrides Sub ButtonNewComment_Click(sender As Object, e As EventArgs)
Dim command As New InsertCommentCommand(Me.AssociatedRichTextEditor.RichTextBoxElement)
Me.ExecuteCommand(command)
End Sub
Protected Overrides Sub ButtonDeleteComment_Click(sender As Object, e As EventArgs)
Dim command As New DeleteCommentCommand(Me.AssociatedRichTextEditor.RichTextBoxElement)
Me.ExecuteCommand(command)
End Sub
Protected Overrides Sub ButtonPreviousComment_Click(sender As Object, e As EventArgs)
Dim command As New GoToPreviousCommentCommand(Me.AssociatedRichTextEditor.RichTextBoxElement)
Me.ExecuteCommand(command)
End Sub
Protected Overrides Sub ButtonNextComment_Click(sender As Object, e As EventArgs)
Dim command As New GoToNextCommentCommand(Me.AssociatedRichTextEditor.RichTextBoxElement)
Me.ExecuteCommand(command)
End Sub
Protected Overrides Sub ToggleButtonShowHideComments_ToggleStateChanged(sender As Object, args As StateChangedEventArgs)
Dim command As New ToggleCommentsCommand(Me.AssociatedRichTextEditor.RichTextBoxElement)
Me.ExecuteCommand(command)
End Sub
Protected Overrides Sub ButtonDeleteAllComments_Click(sender As Object, e As EventArgs)
Dim command As New DeleteAllCommentsCommand(Me.AssociatedRichTextEditor.RichTextBoxElement)
Me.ExecuteCommand(command)
End Sub
Protected Overrides Sub HandleDocumentCommandExecuted(document As RadDocument)
MyBase.HandleDocumentCommandExecuted(document)
Dim hasComments As Boolean = Me.AssociatedRichTextEditor.Document.EnumerateChildrenOfType(Of CommentRangeStart)().Count() > 0
Me.buttonPreviousComment.Enabled = hasComments
Me.buttonNextComment.Enabled = hasComments
Me.buttonDeleteComment.Enabled = hasComments
Me.buttonDeleteAllComments.Enabled = hasComments
End Sub
End Class
To reproduce:
1.Use the provided xml file in the following article: http://www.telerik.com/help/winforms/richtexteditor-localization.html and change these strings:
"Documents_ParagraphPropertiesDialog_TextAlignment_Center": "Mittig";
"Documents_ParagraphPropertiesDialog_TextAlignment_Justify": "Block";
"Documents_ParagraphPropertiesDialog_TextAlignment_Left": "Links";
"Documents_ParagraphPropertiesDialog_TextAlignment_Right": "Rechts";
2.Afterwards, specify the RichTextBoxLocalizationProvider.CurrentProvider by loading the modified file.
3.Run the application, select some paragraph and try to change its alignment. As a result when the ParagraphPropertiesDialog is opened, incorrect alignment text is displayed in the drop-down. If you select a new value a handled ArgumentException is thrown and the paragraph is not aligned at all.
Workaround: use a custom ParagraphPropertiesDialog:
public Form1()
{
RichTextBoxLocalizationProvider.CurrentProvider = RichTextBoxLocalizationProvider.FromFile(@"..\..\RichTextBoxStrings - Copy.xml");
InitializeComponent();
this.radRichTextEditor1.RichTextBoxElement.ParagraphPropertiesDialog = new CustomDialog();
}
public partial class CustomDialog : ParagraphPropertiesDialog
{
public CustomDialog()
{
InitializeComponent();
FieldInfo fi = typeof(ParagraphPropertiesDialog).GetField("radButtonOK",
BindingFlags.Instance | BindingFlags.NonPublic);
RadButton btn = fi.GetValue(this) as RadButton;
btn.MouseDown += btn_MouseDown;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (selectedItem != null)
{
ButtonAlignement.Text = selectedItem.Text;
}
}
public RadDropDownButton ButtonAlignement
{
get
{
FieldInfo fi = typeof(ParagraphPropertiesDialog).GetField("radDropDownButtonAlignement",
BindingFlags.Instance | BindingFlags.NonPublic);
RadDropDownButton radDropDownButtonAlignement = fi.GetValue(this) as RadDropDownButton;
return radDropDownButtonAlignement;
}
}
RadMenuItem selectedItem = null;
RadDropDownButton radDropDownButtonAlignement = null;
private void btn_MouseDown(object sender, MouseEventArgs e)
{
foreach (RadMenuItem item in ButtonAlignement.Items)
{
if (item.Text == ButtonAlignement.Text)
{
selectedItem = item;
break;
}
}
if (selectedItem != null)
{
ButtonAlignement.Text = selectedItem.Tag.ToString();
}
}
}
To reproduce: use the code snippet below. Please refer to the attached screenshot.
public Form1()
{
RichTextBoxLocalizationProvider.CurrentProvider = new MyRichTextBoxLocalizationProvider();
InitializeComponent();
}
public class MyRichTextBoxLocalizationProvider : RichTextBoxLocalizationProvider
{
public override string GetLocalizedString(string id)
{
return base.GetLocalizedString(id);
}
}
Workaround:
Modify the XML file containing all the strings RichTextBoxLocalizationProvider.CurrentProvider = RichTextBoxLocalizationProvider.FromFile(@"C:\RichTextBoxStrings.xml");. You can download a XML file that contains all the currently used strings from here: http://www.telerik.com/docs/default-source/ui-for-winforms/richtextboxstrings.zip?sfvrsn=2
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;
}
}
To reproduce:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">body {
font-family: Segoe UI;
} a {
color: #5cb85c;
} a:hover {
color: #000000;
}</style>
<title>My first HTML document</title>
</head>
<body>
<span style="font-size: 14px; margin-bottom: 5px; display:block;">The Title</span>
<ul style="list-style-type:none; padding-left: 0px; margin-left: 0px;">
<li style="margin-left: 0px; padding-left: 0px; font-size: 12px;">
<a href="www.myurl.com">My URL</a>
</li>
<li style="margin-left: 0px; padding-left: 0px; font-size: 12px;">
<a href="https://www.myurl2.com/">My URL 2</a>
</li>
</ul>
</body>
</html>
To reproduce:
public Form1()
{
InitializeComponent();
this.radRichTextEditor1.IsReadOnly = true;
}
Workaround:
private void Form1_Load(object sender, EventArgs e)
{
this.radRichTextEditor1.IsReadOnly = true;
Telerik.WinControls.RichTextEditor.UI.DocumentWebLayoutPresenter webLayoutPresenter =
this.radRichTextEditor1.RichTextBoxElement.ActiveEditorPresenter as Telerik.WinControls.RichTextEditor.UI.DocumentWebLayoutPresenter;
webLayoutPresenter.Caret.Width = 0;
}
Workaround:
public partial class Form1 : Form
{
private Telerik.WinForms.RichTextEditor.RichTextBoxUI.Dialogs.SpellCheckingDialog spellDlg;
public Form1()
{
InitializeComponent();
}
private void radButton1_Click(object sender, EventArgs e)
{
this.spellDlg = new Telerik.WinForms.RichTextEditor.RichTextBoxUI.Dialogs.SpellCheckingDialog();
Telerik.WinForms.Documents.UI.Extensibility.SpellCheckingUIManager manager = new Telerik.WinForms.Documents.UI.Extensibility.SpellCheckingUIManager(this.radRichTextEditor1.RichTextBoxElement);
FieldInfo fi = this.spellDlg.GetType().GetField("suggestionsListBox", BindingFlags.NonPublic | BindingFlags.Instance);
RadListControl suggestionListBox = fi.GetValue(this.spellDlg) as RadListControl;
suggestionListBox.DataBindingComplete -= suggestionListBox_DataBindingComplete;
suggestionListBox.DataBindingComplete += suggestionListBox_DataBindingComplete;
this.spellDlg.ShowDialog(manager, this.radRichTextEditor1.RichTextBoxElement);
}
private void suggestionListBox_DataBindingComplete(object sender, ListBindingCompleteEventArgs e)
{
if (((RadListControl)sender).Items.Count == 0)
{
FieldInfo fiBtnChange = this.spellDlg.GetType().GetField("buttonChange", BindingFlags.NonPublic | BindingFlags.Instance);
RadButton btnChange = fiBtnChange.GetValue(this.spellDlg) as RadButton;
btnChange.Enabled = false;
FieldInfo fiBtnChangeAll = this.spellDlg.GetType().GetField("buttonChangeAll", BindingFlags.NonPublic | BindingFlags.Instance);
RadButton btnChangeAll = fiBtnChangeAll.GetValue(this.spellDlg) as RadButton;
btnChangeAll.Enabled = false;
}
}
}
To reproduce:
Use the following code and then select some text:
private void radButton1_Click(object sender, EventArgs e)
{
TxtFormatProvider txtProvider = new TxtFormatProvider();
RichTextEditor.Document = txtProvider.Import(sampleText);
RichTextEditor.Document.LineSpacingType = LineSpacingType.Exact;
RichTextEditor.Document.LineSpacing =10;
DocumentPosition startPosition = RichTextEditor.Document.CaretPosition;
DocumentPosition endPosition = new DocumentPosition(startPosition);
startPosition.MoveToStartOfDocumentElement(RichTextEditor.Document);
endPosition.MoveToEndOfDocumentElement(RichTextEditor.Document);
RichTextEditor.Document.Selection.Clear();
RichTextEditor.Document.Selection.AddSelectionStart(startPosition);
RichTextEditor.Document.Selection.AddSelectionEnd(endPosition);
RichTextEditor.RichTextBoxElement.ChangeFontFamily(new Telerik.WinControls.RichTextEditor.UI.FontFamily("Segoe UI"));
RichTextEditor.RichTextBoxElement.ChangeFontSize(Unit.PointToDip(10));
RichTextEditor.Document.Selection.Clear();
}
Workaround:
RichTextEditor.Document.LineSpacingType = LineSpacingType.Auto;
RichTextEditor.Document.LineSpacing =.5;
To reproduce:
- Add RichTextEditorRibbonBar and associate it with RadRichTextEditor at design time.
- Show the form and then force the garbage collector.
Workaround:
- Associate the controls in the load event.
- Set the AssociatedRichTextEditor to null just before the form is closed.
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
richTextEditorRibbonBar1.AssociatedRichTextEditor = radRichTextEditor1;
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
richTextEditorRibbonBar1.AssociatedRichTextEditor = null;
base.OnClosing(e);
}