This is a migrated thread and some comments may be shown as answers.

Clearing text in span

5 Answers 93 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Jennifer
Top achievements
Rank 1
Jennifer asked on 16 Aug 2010, 05:47 PM
I am saving the XAML for a RadDocument in a database. I would like to replace certain text with inlineUIElements. I am able to find the text and add the elements (textboxes), but when I try to set the old span text to an empty string the Text property remains unchanged. 
tempSpan.Text = "";

I have also tried to remove the Span from the Paragraph, but this gives a not implemented error:
tempPara.Children.Remove(tempSpan)

I also tried creating a new RadDocument by iterating through sections, paragraphs, and spans. For the span including the substitution I tried to write the new elements, and for the others to just copy the old elements. The Style didn't seem to come through. The following is the sample that I am working with, and incidentally, the first apostrophe does not work, while the second does.

<t:RadDocument version="1.0" LayoutMode="Flow" PageViewMargin="0,0" DefaultPageLayoutSettings="800,1140" ParagraphDefaultSpacingAfter="0" SectionDefaultPageMargin="6,6,6,6" xmlns:t="clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <t:Section PageMargin="6,6,6,6">
      <t:Paragraph SpacingAfter="0">
        <t:Span Text=" This is a " FontFamily="Verdana"></t:Span>
        <t:Span Text="test" FontFamily="Verdana" UnderlineDecoration="Line" ForeColor="#FFFF0000" HighlightColor="#FFFFFF00"></t:Span>
        <t:Span Text="." FontFamily="Verdana" ForeColor="#FFFF0000" HighlightColor="#FFFFFF00"></t:Span>
      </t:Paragraph>
      <t:Paragraph SpacingAfter="0"></t:Paragraph>
      <t:Paragraph SpacingAfter="0">
        <t:Span Text="And " FontFamily="Verdana"></t:Span>
        <t:Span Text="another" FontFamily="Verdana" FontWeight="Bold"></t:Span>
        <t:Span Text="." FontFamily="Verdana"></t:Span>
      </t:Paragraph>
      <t:Paragraph SpacingAfter="0"></t:Paragraph>
      <t:Paragraph SpacingAfter="0">
        <t:Span Text="A third." FontFamily="Verdana"></t:Span>
      </t:Paragraph>
      <t:Paragraph SpacingAfter="0"></t:Paragraph>
      <t:Paragraph SpacingAfter="0">
        <t:Span Text="I wonder what would happen here |{60C5C54E-0230-DE11-A1B0-0003FF4E47B3}| if this got so terribly long. Don&apos;t know. Let&apos;s find out if this works." FontFamily="Verdana"></t:Span>
      </t:Paragraph>
    </t:Section>
  </t:RadDocument>


Is this possible to do, and if so, what is the correct method?

Thank you,

Jennifer

5 Answers, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 17 Aug 2010, 08:35 AM
Hello Jennifer,

We couldn't reproduce your issues - neither with Remove, nor with the apostrophes. Can you please send us a project which demonstrates these problems so we can further assist you?

Best wishes,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jennifer
Top achievements
Rank 1
answered on 17 Aug 2010, 01:07 PM
Thank you for your help. I submitted the sample project as a support ticket. Ticket ID is : 339371

Jennifer
0
Ivailo Karamanolev
Telerik team
answered on 17 Aug 2010, 01:18 PM
Hello Jennifer,

Thank you, I'll address your issues in the respective ticket.

All the best,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kjell
Top achievements
Rank 1
answered on 25 Jan 2011, 03:01 AM
I'm having a similar problem.  I basically just need the richtextbox to behave like a regular textbox + have spellcheck.  I'm trying to keep it as simple as possible, so I'm just using one span and setting the .text value.  The problem is I also can't clear the span or even set it to " ".  I can set it to "  " but this is causing other weird problems. 
0
Ivailo Karamanolev
Telerik team
answered on 27 Jan 2011, 09:46 AM
Hi Kjell,
The best and probably easiest thing, especially for your case when you need no formatting is to use:
radRichTextBox.Document = new TxtFormatProvider().Import(documentText);
This will create a new RadDocument containing documentText in a single Span (assuming no new lines in the string). Since you have no formatting information, nothing will be lost and the desired text will be shown. Just make sure to disable the floating mini toolbar and all other formatting UI so things don't get messed up.
Let us know if you require additional assistance.

Best wishes,
Ivailo
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
RichTextBox
Asked by
Jennifer
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Jennifer
Top achievements
Rank 1
Kjell
Top achievements
Rank 1
Share this question
or