我在 groupBox 中有一些 radionButtons,我需要执行我称之为“其中一个 radiobuttons.checked 已更改”的操作,或者从 radiobutton 中找出哪些索引已更改。 我试图在事件列表中找到它,但找不到合适的。
编辑: 更清楚地说:我需要知道是否存在一些 handel 用于我将为 goupBox 而不是单个 radioButton 编写的处理程序方法。我知道如何使用 radiButton.checkedChanged,但这不是我发现的.. 或者不同的是,我需要知道 groupBox 在监视这个 groupBox 内部发生的事情时有哪些选项——我的意思是只有 groupBox 的处理程序。我正在寻找处理程序“在组框中发生了一些事情”或类似的情况(如果存在的话)。
它位于 Visual Studio 2012 的WFA(Windows 演示应用程序)中。
最佳答案
我认为您想要做的是将所有 RadioButtons 的 CheckedChanged 事件连接到同一个处理程序。
public Form1()
{
radioButton1.CheckedChanged += new EventHandler(radioButtons_CheckedChanged);
radioButton2.CheckedChanged += new EventHandler(radioButtons_CheckedChanged);
// ...
}
private void radioButtons_CheckedChanged (object sender, EventArgs e)
{
RadioButton radioButton = sender as RadioButton;
if (radioButton1.Checked)
{
// Do stuff
}
else if (radioButton2.Checked)
{
// Do other stuff
}
}
关于c# - C# 中带单选按钮的 groupBox 的事件处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11160594/