Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MessageBox.Show() fonts

Is there a way I can change the font types in a MessageBox.Show() to get bigger size, bold, italic styles?

like image 201
Rabin Avatar asked Jul 11 '10 03:07

Rabin


1 Answers

You can always make your own MessageBox creating a new Windows.Forms class:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MessageBoxFont
{
    public partial class Message : Form
    {
        public Message(String text)
        {
            InitializeComponent();
            tbxMessage.Text = text;
            btnOK.Focus();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

Then you can control the properties (like the font, size, color and the like) shown under the solution explorer. You initialize this form like this:

        private void OpenMessageBox()
        {
            String text = "This is a sample error message";
            Message message = new Message(text);
            message.Show();
        }

Its a work-around, however, easier to implement :)

like image 103
Benny Skogberg Avatar answered Oct 03 '22 16:10

Benny Skogberg