- 打卡等级:常驻代表
- 打卡总天数:34
- 打卡月天数:6
- 打卡总奖励:9027
- 最近打卡:2025-12-17 23:15:51
管理员
- 积分
- 22569
|
|
Winform 设置 RichTextBox 控件字体大小和样式, 设置 FontStyle (粗体, 斜体, 下划线, 删除线), ForeColor (字体颜色)
新建窗体,拖拽一个 RichTextBox 控件到窗体 - using System;
- using System.Windows.Forms;
-
- namespace DemoWinForm
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
-
- // 设置字体为“宋体”
- this.richTextBox1.Font = new System.Drawing.Font("SimSun", 8.25F);
-
- // 设置字体风格, 加粗
- // System.Drawing.FontStyle.Regular = 常规
- // System.Drawing.FontStyle.Bold = 加粗
- // System.Drawing.FontStyle.Italic = 倾斜
- // System.Drawing.FontStyle.Underline = 下划线
- // System.Drawing.FontStyle.Strikeout = 删除线
- this.richTextBox1.Font = new System.Drawing.Font(this.richTextBox1.Font, System.Drawing.FontStyle.Bold);
- // 或者
- // this.richTextBox1.Font = new System.Drawing.Font("SimSun", 8.25F, System.Drawing.FontStyle.Bold);
-
- // 设置字体显示颜色为红色
- this.richTextBox1.ForeColor = System.Drawing.Color.Red;
- }
- }
- }
复制代码
|
|