Telerik UI For WinForms RadMessageBox字体大小

时间:2017-07-10 02:19:18

标签: telerik

有没有办法在不必创建自定义主题的情况下为整个应用程序增加RadMessageBox的默认字体大小?

如果没有,如何在Visual Style Builder中增加默认主题的字体?我尝试增加标签和按钮字体大小,但样式构建器重置了托管消息框的整个表单,看起来非常简单并剪切了标签的文本(参见附件截图)。

enter image description here

谢谢。

1 个答案:

答案 0 :(得分:1)

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

  1. 实现在创建任何表单和/或RadMessageBox之前调用的方法(' SetTelerikControlStyles')。你只需要调用一次这个方法!
  2. 在步骤1的创建方法中添加以下代码行:

    RadMessageBox.Instance.FormElement.TitleBar.Font = new Font("Calibri", 25f);
    RadMessageBox.Instance.Controls["radLabel1"].Font = new Font("Calibri", 50f, FontStyle.Regular);
    
  3. 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);
                }
            }
        }
    }