如何更改 XRRichText 的默认字体大小?

How can I change the default font size of a XRRichText?

我找不到更改 XRRichText 大小的方法,我在属性中更改了字体大小,但是当我执行我的项目时,不保存我所做的更改。

谁能建议我如何更改 XRRichText 的字体大小?谢谢。

查看此处的建议 - How do I change Default Font for XRRichText.

This is expected behavior of a bound XRRichText control. Please review the XRRichTextEdit font thread where this question has been answered.

请使用 RichEditControl 实例在 XtraReport.BeforePrint 事件中更改 XRRichText 控件中的字体。在那里您可以在控件中设置 rtf 以使用自定义字体显示它。这是一些示例代码:

   ...
        public XtraReport1()
        {
            InitializeComponent();
            this.xrRichText1.Html = @"<html><head><title>MyTitle</title></head><body><p>Test</p></body></html>";
        }

        private void XtraReport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            RichEditControl richEditControl1 = new RichEditControl();
            richEditControl1.RtfText = this.xrRichText1.Rtf;
            Document doc = richEditControl1.Document;
            DocumentRange range = richEditControl1.Document.Range;
            CharacterProperties cp = doc.BeginUpdateCharacters(range);
            cp.FontName = "Comic Sans MS";
            cp.FontSize = 18;
            cp.ForeColor = Color.Yellow;
            cp.BackColor = Color.Blue;
            cp.Underline = UnderlineType.DoubleWave;
            cp.UnderlineColor = Color.White;
            doc.EndUpdateCharacters(cp);
            this.xrRichText1.Rtf = richEditControl1.RtfText;
            richEditControl1.Dispose();
        }
    ...

XrRichText Default Font
另一种方法是您还可以为 HTML 绑定使用 FormatString 设置。将格式字符串设置为此即可。

FormatString = <div style="font-family:Arial; font-size:9.75pt;">{0}</div>

它有效,即使我的 HTML 值包含 <head><body> 元素。

参考文献:
Web Report Designer - How to specify default font
XRRichText - Font settings aren't applied correctly

希望对您有所帮助..