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

Changing/Adding to the Style Gallery

1 Answer 57 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Shahrzade
Top achievements
Rank 1
Shahrzade asked on 10 Mar 2016, 01:09 PM

Hei,

 

I would like to do some changes to the RichTextEditorRibbonBar's style gallery like changing the "Normal" style and adding/deleting new/existing styles.

How can I do it programmatically?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 11 Mar 2016, 04:14 PM
Hello ,

Thank you for writing.

In order to accomplish your task, you would need to work with the StyleRepository object exposed by the RadDocument class. Detailed information is available in the following documentation article: RadRichTextEditor | Styles.

Please also check my code snippet below demonstrating how you can create a new style and modify an existing one: 
// Add a new style
StyleDefinition charStyle = new StyleDefinition();
charStyle.Type = StyleType.Character;
charStyle.SpanProperties.FontFamily = new Telerik.WinControls.RichTextEditor.UI.FontFamily("Calibri");
charStyle.SpanProperties.FontSize = Unit.PointToDip(20);
charStyle.SpanProperties.ForeColor = Colors.Orange;
charStyle.DisplayName = "charStyle";
charStyle.Name = "charStyle";
 
this.radRichTextEditor1.Document.StyleRepository.Add(charStyle);
 
// Modify the normal style
StyleDefinition normalStyle = this.radRichTextEditor1.Document.StyleRepository[RadDocumentDefaultStyles.NormalStyleName];
normalStyle.ParagraphProperties.LineSpacing = 1;
normalStyle.SpanProperties.ForeColor = Colors.Red;

The styles defined in this manner will also be added to the Styles group in the ribbon bar.

I hope this information was useful. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
RichTextEditor
Asked by
Shahrzade
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or