Line spacing not working in Rad rich text box

6 posts, 0 answers
  1. Kiran
    Kiran avatar
    1 posts
    Member since:
    May 2013

    Posted 22 May 2013 Link to this post

    Hi,
    I m using Rad rich text box control in one of my Silverlight project.
    <TelerikControls:RadRichTextBox Grid.Row="5" Grid.ColumnSpan="2" x:Name="BodyTextBox" Background="White" Height="300" VerticalScrollBarVisibility="Visible" TabIndex="6" Margin="4,7,0,0" FontSize="12" IsSpellCheckingEnabled="False" AcceptsTab="False" />

    In code on load event I have assigned 
    BodyTextBox.Document.LineSpacingType = LineSpacingType.Exact;
    BodyTextBox.Document.LineSpacing = 0.5;

    if I try to test then its not working as on ENTER it is taking space.
    Please let me know
  2. Deyan
    Admin
    Deyan avatar
    135 posts

    Posted 24 May 2013 Link to this post

    Hello Kiran,

    LineSpacing property controls the spacing between lines in a paragraph. Pressing the Enter key, though, will insert additional paragraph, and the spacing between paragraphs is controlled with Paragraph.SpacingBefore and SpacingAfter properties. You can set the default spacing for all newly added paragraphs using RadDocument.ParagraphDefaultSpacingAfter and ParagraphDefaultSpacingBefore properties.

    If you need to set line spacing as well, note the difference between LineSpacingType.Exact and LineSpacingType.Auto:

    • LineSpacingType.Exact takes LineSpacing value as absolute value, so you have to know the font size in order to choose the appropriate LineSpacing value. For example with LineSpacing value 12 and font-size 12 this will fit the lines within a paragraph without spaces.
    • LineSpacingType.Auto calculates automatically the needed value, which is easier for use. Setting LineSpacing value to 0.5 in this case will make half-row space between the lines in a paragraph.

    You may read more about the different formatting options in this help article.

    Regards,
    Deyan
    the Telerik team

     Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Ramalingam
    Ramalingam avatar
    21 posts
    Member since:
    Apr 2014

    Posted 22 Dec 2014 in reply to Deyan Link to this post

    Hi Deyan,
    Could you please help us on this issue :
    If we hit Enter key, the new line is created with more space. Please suggest a way to create a next line with less space. We tried following code , however it's not working

     richTextEditor.Document.LineSpacingType = LineSpacingType.Exact;
     richTextEditor.DocumentInheritsDefaultStyleSettings = true;

     richTextEditor.Document.LineSpacing = 0;
     richTextEditor.Document.ParagraphDefaultSpacingAfter = 0;
     richTextEditor.Document.ParagraphDefaultSpacingBefore = 0;

    Please refer to the following attachments
    "Current behavior - Next line with more space.png"
    "Expected behavior - Next line with less space.png"

    I have also posted this question last week :

    http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=890478

    Thanks,
    Obuliraj Ramalingam
  5. Ramalingam
    Ramalingam avatar
    21 posts
    Member since:
    Apr 2014

    Posted 22 Dec 2014 in reply to Ramalingam Link to this post

    I think in previous post, we need to set false for "DocumentInheritsDefaultStyleSettings"

    richTextEditor.DocumentInheritsDefaultStyleSettings = false;
  6. Deyan
    Admin
    Deyan avatar
    135 posts

    Posted 22 Dec 2014 Link to this post

    Hello Obuliraj Ramalingam,

    Thank you for contacting us.

    In order to achieve the effect shown in "expected-behavior---next-line-with-less-space.png" you may use the following code snippet:
    richTextEditor.Document.LineSpacingType = LineSpacingType.AtLeast;
    richTextEditor.Document.LineSpacing = 0;
    richTextEditor.Document.ParagraphDefaultSpacingAfter = 0;
    richTextEditor.Document.ParagraphDefaultSpacingBefore = 0;

    I hope this is helpful.

    Regards,
    Deyan
    the Telerik team
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Ramalingam
    Ramalingam avatar
    21 posts
    Member since:
    Apr 2014

    Posted 24 Dec 2014 in reply to Deyan Link to this post

    Hi,
    Thanks a lot for solution. It's working now.

    Thanks,
    Obuliraj Ramalingam
Back to Top
DevCraft banner