This is a migrated thread and some comments may be shown as answers.

About html content (RadRichTextBox + HtmlDataProvider)

2 Answers 243 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Hans
Top achievements
Rank 1
Hans asked on 04 May 2012, 02:30 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Ivailo Karamanolev
Telerik team
answered on 08 May 2012, 11:36 AM
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 >>

0
Hans
Top achievements
Rank 1
answered on 08 May 2012, 02:19 PM
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


Tags
RichTextBox
Asked by
Hans
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Hans
Top achievements
Rank 1
Share this question
or