How to set default font for RichEditControl

By FoxLearn 10/23/2024 2:50:36 AM   64
To set the default font for a RichEditControl in DevExpress, you can follow these steps.

The RichEditControl.Appearance.Text.Font property is initialized in the Form.Designer file.

this.richEditControl.Appearance.Text.Font = ((System.Drawing.Font)(resources.GetObject("richEditControl.Appearance.Text.Font")));  
this.richEditControl.Appearance.Text.Options.UseFont = true;  

This property takes precedence over the RichEditControl.Document.DefaultCharacterProperties properties by default.

To fix the issue, either remove the relevant lines from the Form.Designer file or set the RichEditControl.Options.Behavior.FontSource property to RichEditBaseValueSource.Document.

richEditControl.Options.Behavior.FontSource = RichEditBaseValueSource.Document;
richEditControl.Document.DefaultCharacterProperties.FontName = "Arial";
richEditControl.Document.DefaultCharacterProperties.FontSize = 12;

This approach allows you to effectively set and customize the default font for a RichEditControl in your DevExpress application.