MessageBox.Show()字体 [英] MessageBox.Show() fonts

查看:1981
本文介绍了MessageBox.Show()字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,我可以在MessageBox.Show更改字体类型(),以获得更大的大小,粗体,斜体?

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

推荐答案

您可以随时让你自己的MessageBox创建一个新的Windows.Forms的类:

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

这篇关于MessageBox.Show()字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆