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

Richtext box not selecting proper span text

1 Answer 115 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Faheem
Top achievements
Rank 1
Faheem asked on 25 Jul 2011, 09:05 AM
I ve created span form code behind see the code:
public MainWindow()
     {
         InitializeComponent();
         Telerik.Windows.Documents.Model.Section section = new Telerik.Windows.Documents.Model.Section();
         Telerik.Windows.Documents.Model.Paragraph paragraph = new Telerik.Windows.Documents.Model.Paragraph();
         Telerik.Windows.Documents.Model.Span span = new Telerik.Windows.Documents.Model.Span("span1. dfgfdgfd ");
         Telerik.Windows.Documents.Model.Span span2 = new Telerik.Windows.Documents.Model.Span("span2.");
 
         paragraph.Inlines.Add(span);
         paragraph.Inlines.Add(span2);
         section.Blocks.Add(paragraph);
         radRichTextBox1.Document.Sections.Add(section);
     }
on selection of current span using GetCurrentSpanBox().Text when the cursor is on "dfgfdgfd " i should get this "span1. dfgfdgfd " but i m getting "dfgfdgfd" this only. it recognize "SPACE" as a span. why?
private void radRichTextBox1_MouseUp(object sender, MouseButtonEventArgs e)
     {
         textBox1.Text = radRichTextBox1.Document.CaretPosition.GetCurrentSpanBox().AssociatedSpan.Text;
     }

1 Answer, 1 is accepted

Sort by
0
Alex
Telerik team
answered on 27 Jul 2011, 03:21 PM
Hi Faheem,

Unfortunately we were unable to reproduce the issue reported with the 2011 Q2 version of the controls. I've attached the sample project that that we tested with. It uses the code you posted.

Note however, that no matter where you click in the rich text box the result that gets displayed is always "span1. dfgfdgfd span2.". This is because the two spans that are initially constructed have the same style and therefore are merged into single span when document is displayed. This is the expected behavior in such case.

Please don't hesitate to contact us if you have more questions.

Best wishes,
Alex
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
RichTextBox
Asked by
Faheem
Top achievements
Rank 1
Answers by
Alex
Telerik team
Share this question
or