问题描述
我在groupBox中有一些radionButton,我需要做一些动作,我可以称之为radiobuttons.checked changed或者从radiobutton发现什么索引被更改。我尝试在事件列表中找到它,但找不到正确的。
编辑:
为了使其更加清晰:我需要知道是否存在一些手段,我将编写处理程序方法对于goupBox不是单个radioButton。我知道如何使用radiButton.checkedChanged,但它不是我发现..
或不同的是,我需要知道什么选项有groupBox监视在这个groupBox内发生什么 - 我的意思是只有处理程序的groupBox 。我正在找到处理程序在组框中有事情发生或类似的存在。
它在 WFA(Windows Presentation Application)
我想你想做的是将所有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单选按钮;
if(radioButton1.Checked)
{
// Do stuff
}
else if(radioButton2.Checked)
{
//做其他的东西
}
}
I have some radionButtons in groupBox and I need to do action what I could call "one of radiobuttons.checked changed" or find out from radiobutton what index is changed.I've tryed to find it in list of events but I couldn't find the right one.
Edit:To make it more clear: I need to know if exist some handel for what I'll write handler method for the goupBox not for single radioButton. I know how to use radiButton.checkedChanged, but it's not what I'm finding ..Or differently I need to know what options have the groupBox in monitoring what happens inside this groupBox - I mean only the handlers for the groupBox. I'm finding handler "in the group box is something happens" or simimilar if any exist.
It's in WFA (Windows Presentation Application) in Visual studio 2012.
I think what you want to do is wire up all of the RadioButtons' CheckedChanged event to the same handler.
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#中使用radioButton的groupBox的事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!