c#——radioButton选择判断事件
/// <summary> /// radiobutton按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void radioButtonMirrorLightClick(object sender, EventArgs e) { //把object类型,赋值为当前按下的控件 RadioButton radioButtonClick = sender as RadioButton; if (radioButtonClick.Checked) { switch (radioButtonClick.Name) { case "radioButtonMirrorLight1": ChangeRadiobutton(0); break; case "radioButtonMirrorLight2": ChangeRadiobutton(1); break; case "radioButtonMirrorLight3": ChangeRadiobutton(2); break; case "radioButtonMirrorLight4": ChangeRadiobutton(3); break; default: break; } } }
废话少说,直接上代码
在上面四个radioButton按钮中都添加同一个click事件
则可以判断具体按了哪一个,在取执行其逻辑