New line vs New paragraph

3 posts, 1 answers
  1. Kenneth
    Kenneth avatar
    101 posts
    Member since:
    Apr 2014

    Posted 31 Aug 2014 Link to this post

    This has always frustrated me in ms word, spacing between paragraphs is larger than a line, double line I suppose, and the concept of a line has gone away replaced with line wrapping.

    So I want to insert three lines (not paragraphs) into my Q2 2014 Richtextbox.  When I do editor.InsertLine("") I get a paragraph.  I can set the ParagraphDefaultSpacingAfter to 0 and get my desired effect, but I would rather just insert a line.

    How would I do that?
  2. Answer
    Petya
    Admin
    Petya avatar
    975 posts

    Posted 03 Sep 2014 Link to this post

    Hi Kenneth,

    You can insert a line break with the Alt+Enter keyboard shortcut. Programmatically this is achieved with the InsertLineBreak() method of RadRichTextBox or RadDocumentEditor.
    this.radRichTextBox.InsertLineBreak();

    Note that lines separated in this manner are still interpreted as part of the same Paragraph document element. What you should be aware of is that extremely large document elements can cause performance diminishment when scrolling and typing in the control, so I would not recommend replacing all paragraph ends with a line break. Instead, you can simply change the default spacing after of the Normal style:
    this.radRichTextBox.Document.StyleRepository.GetValueOrNull(RadDocumentDefaultStyles.NormalStyleName).ParagraphProperties.SpacingAfter = 0;

    I hope this is useful.

    Regards,
    Petya
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. Kenneth
    Kenneth avatar
    101 posts
    Member since:
    Apr 2014

    Posted 03 Sep 2014 in reply to Petya Link to this post

    InsertLineBreak() works.  Please note that the Alt+Enter keyboard shortcut not work for me. (which does not matter).
Back to Top