c#加粗代码_C# 字体加粗按钮

C# 字体加粗按钮

关注:109  答案:2  mip版

解决时间 2021-01-28 11:59

e6cb1a03ad541b3098697807b7bf1798.png

提问者鉨瞞着所囿亾,爱着誰

2021-01-27 23:40

C# 字体加粗按钮 怎么写···

最佳答案

e6cb1a03ad541b3098697807b7bf1798.png

二级知识专家孤寡少年

2021-01-27 23:58

比如,把文本框 textBox1 的字体加粗,这样写: private void button1_Click(object sender, EventArgs e)

{

Font newFont;

newFont = new Font(textBox1.Font, textBox1.Font.Style | FontStyle.Bold);

this.textBox1.Font = newFont;

this.textBox1.Focus();

}

全部回答

e6cb1a03ad541b3098697807b7bf1798.png

1楼試著忘記壹切

2021-01-28 00:34

用个label为例子,当然你其他可以有文字显示的控件都可以

label label1=new label();

private void button1_click(object sender, eventargs e)

{//更改样式

if (label1.font.fontfamily.name == "宋体")

label1.font = new font("楷体", label1.font.size, label1.font.style);

else label1.font = new font("宋体", label1.font.size, label1.font.style);

}

private void button2_click(object sender, eventargs e)

{//更改粗体

if (label1.font.bold)

label1.font = new font(label1.font, label1.font.style & ~fontstyle.bold);

else

label1.font = new font(label1.font, label1.font.style | fontstyle.bold);

}

private void button3_click(object sender, eventargs e)

{//更改斜体

if (label1.font.italic)

label1.font = new font(label1.font, label1.font.style & ~fontstyle.italic);

else

label1.font = new font(label1.font, label1.font.style | fontstyle.italic);

}

我要举报

如果感觉以上信息为低俗/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!

点此我要举报以上信息!

推荐资讯

大家都在看


版权声明:本文为weixin_39564036原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。