你的位置:首页 > ASP.net教程

[ASP.net教程]CheckStateChanged(复选框选中状态更改事件)和 CheckedChanged(单选按钮选中状态更改事件)二者区别?


CheckStateChanged(复选框选中状态更改事件)和 CheckedChanged(单选按钮选中状态更改事件)二者区别?

在学习复选框控件(CheckBox)和单选按钮控件(RadioButton)用到了上述两种事件,但不明白有何区别:

 1 using System; 2 using System.Data; 3 using System.Drawing; 4 using System.Text; 5 using System.Windows.Forms; 6 namespace Test18 7 { 8   public partial class Form1 : Form 9   {10     public Form1()11     {12       InitializeComponent();13     }14     private void checkBox1_CheckStateChanged(object sender, EventArgs e)15     {16       MessageBox.Show("控件的选择状态发生改变");17     }18 19     private void Form1_Load(object sender, EventArgs e)20     {21 22     }23 24     private void checkBox1_CheckedChanged(object sender, EventArgs e)25     {26 27     }28   }29 }

 1 using System; 2 using System.Data; 3 using System.Drawing; 4 using System.Text; 5 using System.Windows.Forms; 6 namespace Test20 7 { 8   public partial class Form1 : Form 9   {10     public Form1()11     {12       InitializeComponent();13     }14     private void radioButton1_CheckedChanged(object sender, EventArgs e)15     {16       MessageBox.Show("RadioButton1控件的选中状态被更改");17     }18     private void button1_Click(object sender, EventArgs e)19     {20       radioButton1.Checked = true;21     }22     private void button2_Click(object sender, EventArgs e)23     {24       radioButton1.Checked = false;25     }26     private void Form1_Load(object sender, EventArgs e)27     {28       radioButton1.Checked = true;29     }30   }31 }