天天看點

c#加粗代碼_C# 字型加粗按鈕

C# 字型加粗按鈕

關注:109  答案:2  mip版

解決時間 2021-01-28 11:59

c#加粗代碼_C# 字型加粗按鈕

提問者鉨瞞着所囿亾,愛着誰

2021-01-27 23:40

C# 字型加粗按鈕 怎麼寫···

最佳答案

c#加粗代碼_C# 字型加粗按鈕

二級知識專家孤寡少年

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();

}

全部回答

c#加粗代碼_C# 字型加粗按鈕

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

}

我要舉報

如果感覺以上資訊為低俗/不良/侵權的資訊,可以點下面連結進行舉報,我們會做出相應處理,感謝你的支援!

點此我要舉報以上資訊!

推薦資訊

大家都在看