c# - C# 中带单选按钮的 groupBox 的事件处理程序

标签 c# event-handling radio-button groupbox

我在 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/

相关文章:

asp.net - 用户控件事件不会在 Httphandler 中触发

jQuery 单选按钮组.change 方法

c# - 查找与其他列表元素有 3 个属性相似的列表元素,然后将第二个元素的值添加到第一个元素

c# - 从 C# 中的字符串末尾删除单引号

c# - 动态添加控件和事件处理程序 C#

java - 在 JAVA 中处理事件的正确方法是什么?

javascript - 无法读取属性 'Value'

php - 添加单选按钮到 MySQL 获取结果并使用结果值获取另一条记录...?

c# - 将 dd/mm/yyyy 格式的字符串转换为日期时间

c# - Excel DNA 代码访问安全性