dpdragnev
dpdragnev

Reputation: 2111

Telerik UI For WinForms RadMessageBox font size

Is there a way to increase the default font size of the RadMessageBox for the whole application without having to create a custom theme?

If not, how to just increase the font on the default theme in Visual Style Builder? I tried just increasing the label and button font sizes, but the style builder reset the whole form that hosts the message box to look very plain and cutting the text of the label (see attached screenshot).

enter image description here

Thank you.

Upvotes: 2

Views: 1275

Answers (1)

Odrai
Odrai

Reputation: 2353

It is possible to customize the font for all RadMessageBoxes within an application.

  1. Implement a method ('SetTelerikControlStyles') which is called before any form and/or RadMessageBox is created. You only need to call this method once!
  2. Add the following lines of code in the created method of step 1:

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

The FormElement.TitleBar.Font, as the name already reveals, is the title bar of the RadMessageBox.

Telerik is using dynamic named controls, so in this case radLabel1 represents the RadMessageBox text area.


Complete Program.cs sample:

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);
            }
        }
    }
}

Upvotes: 2

Related Questions