我有一个由我的所有单选按钮共享的事件处理程序:
private void radioButtonPackers_CheckedChanged(object sender, EventArgs e)
{
var rb = sender as RadioButton;
if (rb == radioButtonPackers)
{
team = NFCNorth.Packers;
} else if (rb == radioButtonBears)
{
team = NFCNorth.Bears;
} else if . . .
}
rb 始终被视为 radioButtonPackers,即使在我检查了 radioButtonBears、radioButtonVikings 或 radioButtonLions 单选按钮之后也是如此。
我是否必须做类似的事情:
if (radioButtonPackers.Checked)
{
team = NFCNorth.Packers;
}
else if (radioButtonBears.Checked)
{
team = NFCNorth.Bears;
}
. . .
?