Telerik UI 对于 WinForms RadMessageBox 字体大小

Telerik UI For WinForms RadMessageBox font size

有没有办法增加整个应用程序 RadMessageBox 的默认字体大小而无需创建自定义主题?

如果没有,如何在 Visual Style Builder 中增加默认主题的字体?我尝试只增加标签和按钮的字体大小,但样式生成器重置了承载消息框的整个表单,使其看起来非常简单并剪切了标签的文本(请参阅随附的屏幕截图)。

谢谢。

可以为应用程序中的所有 RadMessageBox 自定义字体。

  1. 实施一个方法 ('SetTelerikControlStyles'),该方法在创建任何表单 and/or RadMessageBox 之前调用。这个方法你只需要调用一次!
  2. 在第一步创建的方法中添加如下代码行:

    RadMessageBox.Instance.FormElement.TitleBar.Font = new Font("Calibri", 25f);
    RadMessageBox.Instance.Controls["radLabel1"].Font = new Font("Calibri", 50f, FontStyle.Regular);
    

顾名思义,FormElement.TitleBar.Font是RadMessageBox的标题栏。

Telerik 使用动态命名控件,因此在本例中 radLabel1 代表 RadMessageBox 文本区域。


完成Program.cs样本:

using System;
using System.Drawing;
using System.Windows.Forms;

using Telerik.WinControls;

namespace WindowsFormsApplication
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            SetTelerikControlStyles();

            Application.Run(new Form1());
        }

        private static void SetTelerikControlStyles()
        {
            RadMessageBox.Instance.FormElement.TitleBar.Font = new Font("Calibri", 25f);

            // I added this additional check for safety, if Telerik modifies the name of the control.
            if (RadMessageBox.Instance.Controls.ContainsKey("radLabel1"))
            {
                RadMessageBox.Instance.Controls["radLabel1"].Font = new Font("Calibri", 50f, FontStyle.Regular);
            }
        }
    }
}