在这里用到了flowLayoutPanel这个控件
for (int i = 0; i < listPlan.Count; i++)
{
var rb = new RadioButton { Text = listPlan[i].plan_name }; //控件显示的名称为计划明
flowLayoutPanel1.Controls.Add(rb); //flowLayoutPanel1里加载radiobutton控件
}
显示radiobutton控件的名字
rb .CheckedChanged += new EventHandler(radioButton1_CheckedChanged);
public void radioButton1_CheckedChanged(object sender, EventArgs e)
{
RadioButton Rd = (RadioButton)sender;
//判断是否为当前选中的
if (Rd.Checked)
{
txtInterrupt.Text = Rd.Text; //显示当前选中的值
txtInterrupt.ForeColor = Color.Black;
txtInterrupt.Font = new Font(txtInterrupt.Font.Name, 14);
plan_name = Rd.Text;//plan_name
}
}