如何设置c#的字体风格FontStyle同时为Bold,Italic...

FontStyle   style   =   FontStyle.Regular;   
style   |=   FontStyle.Bold;   
style   |=   FontStyle.Italic;

如果是移除的话可以用:   
style-=FontStyle.Bold;

转载于:https://www.cnblogs.com/easyjacky/archive/2008/03/12/FontStyle.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
C#中,可以使用自定义消息框的方式来实现修改MessageBox中字体颜色的效果。以下是一个示例代码: ```csharp using System.Drawing; using System.Windows.Forms; public static class MessageBoxWithColor { public static DialogResult Show(string text, string caption, Color textColor) { DialogResult result = DialogResult.None; using (Form form = new Form()) { form.FormBorderStyle = FormBorderStyle.FixedDialog; form.MaximizeBox = false; form.MinimizeBox = false; form.StartPosition = FormStartPosition.CenterParent; form.ShowIcon = false; form.BackColor = Color.White; form.Text = caption; Label label = new Label(); label.TextAlign = ContentAlignment.MiddleCenter; label.Font = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); label.ForeColor = textColor; label.Text = text; label.AutoSize = true; label.Location = new Point(20, 20); label.MaximumSize = new Size(400, 0); form.ClientSize = new Size(Math.Min(label.Width + 40, 400), label.Height + 100); form.Controls.Add(label); Button button = new Button(); button.DialogResult = DialogResult.OK; button.Location = new Point(form.ClientSize.Width / 2 - 50, label.Height + 50); button.Size = new Size(100, 30); button.Text = "OK"; button.UseVisualStyleBackColor = true; form.Controls.Add(button); form.AcceptButton = button; result = form.ShowDialog(); } return result; } } ``` 你可以在需要使用MessageBox的地方,调用MessageBoxWithColor.Show方法,来显示自定义的消息框,并设置字体颜色。例如: ```csharp MessageBoxWithColor.Show("这是一条自定义颜色的消息!", "提示", Color.Red); ``` 在上述示例中,自定义了一个名为MessageBoxWithColor的静态类,其中的Show方法接受三个参数:消息文本、标题和字体颜色。在Show方法中,使用了一个Label控件来显示消息文本,并设置了Label的字体颜色。最后,将Label控件添加到Form中,以显示自定义的消息框。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值