I have a telerik radRichTextbox that I need to set some defaults on for all areas that it is dynamically generated but nothing I am doing is working.
Here is my XAML set up below.
What is the proper way to default to SINGLE line spacing and fontsize 12 with font family of Times New Roman?
Obviously the user should be able to change if they wish but I need it to atleast default initially to these values.
Here is my XAML set up below.
<telerik:HtmlDataProvider RichTextBox="{Binding ElementName=radRichTextBox}" Html="{Binding MyRichText, Mode=TwoWay, NotifyOnValidationError=true, TargetNullValue='', ValidatesOnExceptions=true}">
<telerik:HtmlDataProvider.FormatProvider>
<telerik:HtmlFormatProvider>
<telerik:HtmlFormatProvider.ExportSettings>
<telerik:HtmlExportSettings DocumentExportLevel="Fragment"
ImageExportMode="AutomaticInline"
StyleRepositoryExportMode="DontExportStyles"
StylesExportMode="Inline"
ExportEmptyDocumentAsEmptyString="True"
/>
</telerik:HtmlFormatProvider.ExportSettings>
</telerik:HtmlFormatProvider>
</telerik:HtmlDataProvider.FormatProvider>
</telerik:HtmlDataProvider>
<telerik:RadRichTextBox x:Name="radRichTextBox" DocumentInheritsDefaultStyleSettings="True" Foreground="black" FontFamily="Times New Roman" FontSize="12" Padding="10">
</telerik:RadRichTextBox>
What is the proper way to default to SINGLE line spacing and fontsize 12 with font family of Times New Roman?
Obviously the user should be able to change if they wish but I need it to atleast default initially to these values.
Hi Patrick,
Your approach is correct, however, the documents are usually caring these settings as well and this will override the local ones. To achieve this you can change the font after the document is loaded:
private void RadRichTextBox_DocumentChanged(object sender, EventArgs e) { this.radRichTextBox.Document.Selection.SelectAll(); this.radRichTextBox.ActiveDocumentEditor.ChangeFontFamily(new FontFamily("Consolas")); this.radRichTextBox.ActiveDocumentEditor.ChangeFontSize(20); this.radRichTextBox.Document.Selection.Clear(); }
Really just need it to happen on the initial load. Once the user modifies from the default, I don't want to change it automatically for them.
Hi Patrick,
I am not sure why this is not working on your side.
Would it be possible to create a sample project that shows your exact case and send it to me? This will give me a better understanding and I will be able to investigate this.
Thank you in advance for your patience and cooperation.
Hi Patrick,
You can use the following methods for this:
this.radRichTextBox.ActiveDocumentEditor.ChangeParagraphSpacingAfter(0); this.radRichTextBox.ActiveDocumentEditor.ChangeParagraphSpacingBefore(0); this.radRichTextBox.ActiveDocumentEditor.ChangeParagraphLineSpacing(0, LineSpacingType.Exact);