动态加载RadioButton控件

来源:互联网 发布:人族剑士捏脸数据 编辑:程序博客网 时间:2024/05/16 14:56

在这里用到了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            }        }




原创粉丝点击