Insert newline

8 posts, 0 answers
  1. Flemming Rosenbrandt
    Flemming Rosenbrandt avatar
    119 posts
    Member since:
    Mar 2006

    Posted 16 Jun 2010 Link to this post

    Hi

    How do I insert a newline at a specific position (or the caret position)?

    /Flemmig Rosenbrandt
  2. Mike
    Admin
    Mike avatar
    640 posts

    Posted 17 Jun 2010 Link to this post

    Hello Flemmig Rosenbrandt,

    You have generally two options depending on if you wish to insert a line break in a paragraph, or if you need to break a paragraph to two paragraphs. Here is example for each of the two cases that works with the RadRichTextBox Q2 Beta version:

    private void btnAddLineBreak_Click(object sender, RoutedEventArgs e)
    {
        this.radRtb.Document.InsertAtCaretPosition(FormattingSymbolLayoutBox.LINE_BREAK, new Span());
        this.radRtb.UpdateEditorLayout();
    }
     
    private void btnAddParagraph_Click(object sender, RoutedEventArgs e)
    {
        this.radRtb.Document.InsertAtCaretPosition(Environment.NewLine, new Span());
        this.radRtb.UpdateEditorLayout();
    }

    All the best,
    Mike
    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.
  3. Flemming Rosenbrandt
    Flemming Rosenbrandt avatar
    119 posts
    Member since:
    Mar 2006

    Posted 18 Jun 2010 Link to this post

    Thanks. This was just what I needed. It looks fine in the editor.

     

    But if I use the exported html as the message body in an email (using Afterlogic’s MailBee) the first newline is ok and goes to the next line – but the following ones disappear – no matter if I use the first or second solution you suggest.

     

     

    In the exported html – Environment.NewLine / FormattingSymbolLayoutBox.LINE_BREAK is converted to the same html:

     

    </p><p class="p_4468A9CA"><span class="s_D8D99854" /> 


     
    Is it possible to achieve this instead?:

     

    <p>&nbsp;</p> 

     
    /Flemming Rosenbrandt

  4. Alex
    Admin
    Alex avatar
    130 posts

    Posted 18 Jun 2010 Link to this post

    Hello Flemming Rosenbrandt,

    Thanks for reporting this issue. We will make sure it is fixed for the official release.
    As a temporary workaround you can try adding single space at the end of the current paragraph when creating new one, thus assuring there are no empty paragraphs in the document. Here is an example:

    private void btnAddParagraph_Click(object sender, RoutedEventArgs e)
    {
        this.radRtb.Document.InsertAtCaretPosition(" " + Environment.NewLine, new Span());
        this.radRtb.UpdateEditorLayout();
    }

    I hope this is helpful. 

    Sincerely yours,
    Alex
    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
  5. Gauri
    Gauri avatar
    25 posts
    Member since:
    Jun 2010

    Posted 02 Oct 2010 Link to this post

    Hello,
    I tried

    FormattingSymbolLayoutBox

     

     

    .LINE_BREAK then it shows exception telling does not contain defination for LINE_BREAK. What to do?

     

     

     

     

     

  6. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 04 Oct 2010 Link to this post

    Hi Gauri,

    You seem to be using an older version of RadRichTextBox. If you switch to the latest version, it should work fine. You can check your assembly references and includes to make sure you have added all of them:
    • Telerik.Windows.Controls;
    • Telerik.Windows.Documents;
    • Telerik.Windows.Controls.Input;
    • Telerik.Windows.Controls.Navigation.

    Also, please note that FormattingSymbolLayoutBox is located in the Telerik.Windows.Documents.Layout namespace, so you have to add a using for that, I you haven't already done so.

    Let us know if that solves the issue.

    All the best,
    Iva
    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
  7. Gauri
    Gauri avatar
    25 posts
    Member since:
    Jun 2010

    Posted 05 Oct 2010 Link to this post

    Hi,
    Thanks for reply.
    I already added mentioned assembly references.

    Also,I add a using Telerik.Windows.Documents.Layout namespace. It shows SPACE_SYMBOL,ENTER_SYMBOL,SPACE_SYMBOL. But didnt have for new line. Can you please reply me back?

  8. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 06 Oct 2010 Link to this post

    Hi Gauri,

    SPACE_SYMBOL, ENTER_SYMBOL and TAB_SYMBOL are the string fields of the FormattingSymbolLayoutBox class in version Q1 SP1 of the controls. They represent the symbols that mark an interval, end of a line and a tab symbol if you have enabled showing the formatting symbols.
     In version Q2 you have:
    • SPACE;
    • SPACE_SYMBOL_VISUAL;
    • TAB;
    • TAB_SYMBOL_VISUAL;
    • LINE_BREAK;
    • LINE_BREAK_VISUAL;
    • ENTER;
    • ENTER_SYMBOL_VISUAL;
    • PAGE_BREAK;
    • PAGE_BREAK_VISUAL.

    The "visual" ones are what appears when enabling the option "Show formatting symbols" and the others is what you need if you want to actually insert an interval/ new line, etc.

    If you are using Blend, the problem is that it might be referencing wrong DLLs versions, although you are prompting it to the right folder. Please remove all Telerik assemblies from the project, restert Blend and then add them again. Please make sure you are adding references to one and the same version of all Telerik assemblies. Let us know if the problem persists.

    I have no other ideas, but I am positive that FormattingSymbolLayoutBox.LINE_BREAK works with Q2 SP1.

    Regards,

    Iva
    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
Back to Top