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

CustomField

1 Answer 54 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
MURAT ERAYDIN
Top achievements
Rank 1
MURAT ERAYDIN asked on 03 Nov 2012, 10:26 AM

Hi,

I've a CustomField class.

public class CustomField : MergeField

I need to return a multiline string from GetResultFragment() function.

 

string result = string.Empty;
result = "First Line";
result += Convert.ToChar(11);
result = "Second Line";
DocumentFragment.CreateFromInline(new Span(result));

But output is not as I've expected. Can GetResultFragment() return Paragraph or is there an other solution?

Regards.


1 Answer, 1 is accepted

Sort by
0
Accepted
Petya
Telerik team
answered on 07 Nov 2012, 12:24 PM
Hi MURAT ERAYDIN,

Revising your code here are our findings. 

First, the result string you are creating accepts a new value at the following line:
result = "Second Line";
I suspect you've made a typo and you actually wanted to append this string, so I'm giving you a heads-up.

For your overall scenario, RadRichTextBox does not support vertical tabulations, so the approach you tried to implement will not work properly.  Actually, this approach is not the correct one when creating a paragraph. Instead, you should use something like this:
protected override DocumentFragment GetResultFragment()
{
    RadDocument doc = new RadDocument();
    Section section = new Section();
    Paragraph paragraph = new Paragraph();
    Span sp = new Span("First Line");
    paragraph.Inlines.Add(sp);
    section.Blocks.Add(paragraph);
 
    Paragraph par = new Paragraph();
    Span sp1 = new Span("Second Line");
    par.Inlines.Add(sp1);
    section.Blocks.Add(par);
 
    doc.Sections.Add(section);
    DocumentFragment fr = new DocumentFragment(doc);
    return fr;
}

Other than that, there are no limitations as to what the GetResultFragment() can return.

I hope this helps. Please get back to us if you need additional assistance.

 
All the best,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
MURAT ERAYDIN
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or