C# winform 中同组多个RadioButton使用技巧方法,因为用到了,总结归类一下,做个记录
可以先定义一个方法,用来处理该组RadioButton,如下:
public void AllRadio_CheckedChanged(object sender, EventArgs e)
{
if (!((RadioButton)sender).Checked)
{
return;
}
string sText = string.Empty;
switch (((RadioButton)sender).Name)
{
case "shRadio":
sText = "查询数据";
panel5.Visible = true;
panel6.Visible = false;
break;
case "mdRadio":
sText = "修改数据";
panel6.Visible = true;
panel5.Visible = false;
break;
case "delRadio":
sText = "删除数据";
panel5.Visible = true;
panel6.Visible = false;
break;
}
groupBox3.Text = sText;
button1.Text = sText;
isModify(true);
}
定义完后,将涉及到的RadioButton的CheckChanged时间选择该方法即可根据button选择对应不同的RadioButton值