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

时间:2021-03-02 14:41:03

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

复选框控件(CheckBox)提供了CheckedChanged控件的选择状态发生改变;双击即可进入CheckedChanged编辑界面,此按钮未提供CheckStateChanged事件。

单选按钮控件(RadioButton)提供了CheckStateChanged选中状态被更改,双击单选按钮,可进入CheckedChanged编辑界面。

 using System;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Test18
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void checkBox1_CheckStateChanged(object sender, EventArgs e)
{
MessageBox.Show("控件的选择状态发生改变");
} private void Form1_Load(object sender, EventArgs e)
{ } private void checkBox1_CheckedChanged(object sender, EventArgs e)
{ }
}
}
 using System;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Test20
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
MessageBox.Show("RadioButton1控件的选中状态被更改");
}
private void button1_Click(object sender, EventArgs e)
{
radioButton1.Checked = true;
}
private void button2_Click(object sender, EventArgs e)
{
radioButton1.Checked = false;
}
private void Form1_Load(object sender, EventArgs e)
{
radioButton1.Checked = true;
}
}
}