<span style="font-size:18px;">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _17_字体和颜色对话框
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// 字体窗口
FontDialog fd = new FontDialog();
if (fd.ShowDialog() == DialogResult.OK)
{
// 更新文本框内容的字体
textBox1.Font = fd.Font;
}
}
private void button2_Click(object sender, EventArgs e)
{
// 颜色窗口
ColorDialog cd = new ColorDialog();
if (cd.ShowDialog() == DialogResult.OK)
{
// 更新文本框内容的颜色
textBox1.ForeColor = cd.Color;
}
}
}
}
</span>
C#学习笔记之字体窗口和颜色窗口
最新推荐文章于 2022-06-09 00:39:50 发布