BUG: The RichTextBox control loses formatting when you change the DetectUrls property or the RightToLeft property at run time (814310)
The information in this article applies to:
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
SYMPTOMSWhen you change the DetectUrls property or the RightToLeft property of the RichTextBox control at run time, you lose the rich text formatting. The rich
text is converted to plain text.CAUSE When you change the RightToLeft or DetectUrls property of the RichTextBox at run time, Microsoft .NET Framework cannot preserve the format.
Therefore, you lose the rich text formatting.WORKAROUNDTo work around this bug, copy the rich text to the
Clipboard, and then set the RightToLeft property. Next, copy the text from Clipboard back to rich text.
To do this, use the following code: Visual Basic .NET Code ' Select the Text in TextBox
RichTextBox1.SelectAll()
' Add the Text to the Clipboard
RichTextBox1.Cut()
' Because RightToLeft cannot be set for Empty RichTextBox
' Add Temporary text to RichTextBox
RichTextBox1.Text = "Temp"
' Set RightToLeft to Yes
RichTextBox1.RightToLeft = RightToLeft.Yes
' Paste the Text back to RichTextBox
RichTextBox1.SelectAll()
RichTextBox1.Paste() Visual C# .NET Code // Select the Text in TextBox
richTextBox1.SelectAll();
// Add the Text to the Clipboard
richTextBox1.Cut();
// Because RightToLeft cannot be set for Empty RichTextBox
// Add Temporary text to RichTextBox
richTextBox1.Text = "Temp";
// Set RightToLeft to Yes
richTextBox1.RightToLeft = RightToLeft.Yes;
// Paste the Text back to RichTextBox
richTextBox1.SelectAll();
richTextBox1.Paste(); STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
Modification Type: | Minor | Last Reviewed: | 2/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005doesnotapply kbvs2002sp1sweep kbWindowsForms kbProperties kbRichEdit kbbug KB814310 kbAudDeveloper |
---|
|