使用WinForms; 有没有更好的方法来找到一个组的已检查RadioButton?在我看来,下面的代码不应该是必要的.当你检查一个不同的RadioButton然后它知道哪一个取消选中...所以它应该知道哪个被检查.如何在不执行大量if语句(或切换)的情况下提取该信息.
RadioButton rb = null;
if (m_RadioButton1.Checked == true)
{
rb = m_RadioButton1;
}
else if (m_RadioButton2.Checked == true)
{
rb = m_RadioButton2;
}
else if (m_RadioButton3.Checked == true)
{
rb = m_RadioButton3;
}
Run Code Online (Sandbox Code Playgroud)