About html content (RadRichTextBox + HtmlDataProvider)

3 posts, 1 answers
  1. Hans
    Hans avatar
    26 posts
    Member since:
    May 2012

    Posted 04 May 2012 Link to this post

    Hello
    I use RadRichTextBox and HtmlDataProvider like this

    <telhtml:HtmlDataProvider x:Name="htmlDataProvider"
                    Html="{Binding HtmlContent, Mode=TwoWay}"
                    RichTextBox="{Binding ElementName=HTMLRichTextBox}" />
     
    <telerik:RadRichTextBox x:Name="HTMLRichTextBox"
                    IsImageMiniToolBarEnabled="True"
                    IsSelectionMiniToolBarEnabled="False"
                    IsSpellCheckingEnabled="False"
                    ScrollViewer.HorizontalScrollBarVisibility="Auto"
                    ScrollViewer.VerticalScrollBarVisibility="Auto" />

    When a user is typing, and presses "Enter" between the lines created by a large distance equal to one line. I looked in the "ViewModel" on the property HtmlContent, there is a symbol between the words </ p> (see example below)

    <body>
        <p class="p_E2968D9D">
        <span class="s_E2968D9D">Hello world!</span>
        </p>
     
        <p class="p_E2968D9D">
        <span class="s_E2968D9D">The world is mine ...</span>
        </p>
    </body>

    How do I fix this? As there was no distance between the lines?
  2. Answer
    Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 08 May 2012 Link to this post

    Hello,

    When the user presses enter, RadRichTextBox (and Word too) creates a new paragraph. By default, paragraphs have spacing between them. In order to avoid spacing, users must press Shift+Enter, which enters a line break. If you would like to have multiple paragraphs, but without spacing, you can set the SpacingAfter and SpacingBefore properties of existing paragraphs to 0 and ParagraphDefaultSpacingBefore and ParagraphDefaultSpacingAfter of RadDocument to 0.
    Let us know if that doesn't work for you.

    Greetings,
    Ivailo Karamanolev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Hans
    Hans avatar
    26 posts
    Member since:
    May 2012

    Posted 08 May 2012 Link to this post

    Hello Ivailo Karamanolev!
    Thank you very much for answer. I waited 4 days and was not hoping for an answer!
    It works!


    I took the DocumentArranged event (calls all the time, but suitable)
    private void HTMLRichTextBox_OnDocumentArranged(object sender, EventArgs e)
    {
        foreach (Paragraph paragraph in ((RadRichTextBox) sender).Document.EnumerateChildrenOfType<Paragraph>())
        {
            paragraph.SpacingAfter = 0;
            paragraph.SpacingBefore = 0;
        }
    }

     And I changed my RichText
    <telerik:RadRichTextBox x:Name="HTMLRichTextBox" DocumentArranged="HTMLRichTextBox_OnDocumentArranged" >
        <telerik:RadDocument ParagraphDefaultSpacingBefore="0" ParagraphDefaultSpacingAfter="0" />
    </telerik:RadRichTextBox>

    Differences between the Enter and Shift + Enter - almost no


Back to Top