简体   繁体   中英

MessageBox.Show() fonts

有没有办法我可以更改MessageBox.Show()中的字体类型,以获得更大的大小,粗体,斜体样式?

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 :)

I believe that those fonts are controlled by the operating system.

You could (however) make a custom dialog and put anything you want in there including custom fonts.
Here is the MSDN resource for custom dialogs.
http://msdn.microsoft.com/en-us/library/2chz8edb(VS.90).aspx

Have you thought of something like a customized message box ( www.html-messagebox.com )?

For more customization such as building an irregular shaped message box (Homer Simpson's head), you are better off creating your own MessageBox-like implementation for your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM