C#编程-134:字体颜色对话框

C#编程-134:字体颜色对话框


  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace ColorFontDialogTest
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         private void btnBackColor_Click(object sender, EventArgs e)
  20.         {
  21.             if (colorDialog1.ShowDialog() == DialogResult.OK)
  22.             {
  23.                 this.BackColor = colorDialog1.Color;
  24.             }
  25.         }
  26.  
  27.         private void btnFont_Click(object sender, EventArgs e)
  28.         {
  29.             if (fontDialog1.ShowDialog() == DialogResult.OK)
  30.             {
  31.                 textBox1.Font = fontDialog1.Font;
  32.             }
  33.         }
  34.  
  35.         private void Form1_Load(object sender, EventArgs e)
  36.         {
  37.             textBox1.Text = "测试字体属性的文字,试试这段话的字体属性会不会被修改";
  38.         }
  39.     }
  40. }