2 posts, 1 answers
    MURAT ERAYDIN avatar
    7 posts
    Member since:
    Dec 2009

    Posted 03 Nov 2012 Link to this post


    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?


  2. Answer
    Petya avatar
    983 posts

    Posted 07 Nov 2012 Link to this post


    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 par = new Paragraph();
        Span sp1 = new Span("Second Line");
        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,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top