Graphics g; Font font; Brush brush; string fontString = ""; private void button1_Click(object sender, EventArgs e) { //宋体,14号,蓝色,正常 g = this.CreateGraphics(); font = new Font("宋体", 14); brush = new SolidBrush(Color.Blue); fontString = "宋体,14号,蓝色,正常"; g.DrawString(fontString, font, brush, 20, 10); } private void button2_Click(object sender, EventArgs e) { //宋体,14号,红色,加粗 g = this.CreateGraphics(); font = new Font("宋体", 14,FontStyle.Bold); brush = new SolidBrush(Color.Red); fontString = "宋体,14号,红色,加粗"; g.DrawString(fontString, font, brush, 20, 50); } private void button3_Click(object sender, EventArgs e) { //隶书,16号,绿色,有下划线 g = this.CreateGraphics(); font = new Font("隶书", 16,FontStyle.Underline); brush = new SolidBrush(Color.Green); fontString = "隶书,16号,绿色,有下划线"; g.DrawString(fontString, font, brush, 20, 90); } private void button4_Click(object sender, EventArgs e) { //黑体,20号,灰色,倾斜 g = this.CreateGraphics(); font = new Font("黑体", 20,FontStyle.Italic); brush = new SolidBrush(Color.Blue); fontString = "黑体,20号,灰色,倾斜"; g.DrawString(fontString, font, brush, 20, 130); }
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步