CustomField

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

    Posted 03 Nov 2012 Link to this post

    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.


  2. Answer
    Petya
    Admin
    Petya avatar
    975 posts

    Posted 07 Nov 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top