public Form1() ...{ InitializeComponent(); ar=new ArrayList(); posx=10;posy=10; } private ArrayList ar;//放控件组的arraylist private int posx,posy;//记录每个控件的位置 //控件点击时触发的事件 private void rb_CheckedChanged(object sender, EventArgs e) ...{ RadioButton rb= sender as RadioButton; if(rb!=null ) MessageBox.Show(rb.Text+"选项发生了变化"); else MessageBox.Show("sender不是radiobutton"); } //动态地创建控件,并加入到arraylist中去 private void button2_Click(object sender, System.EventArgs e) ...{ RadioButton rb=new RadioButton(); rb.CheckedChanged+=new EventHandler(rb_CheckedChanged); rb.Size=new Size(100,20); rb.Text=textBox1.Text; posy+=20; rb.Location=new Point(posx,posy); ar.Add(rb); listBox1.Items.Clear(); foreach(RadioButton rab in ar) ...{ listBox1.Items.Add(rab.Text); } } //向groupbox中加入控件 private void button3_Click(object sender, System.EventArgs e) ...{ groupBox1.Controls.Clear(); foreach(RadioButton rb in ar) ...{ this.groupBox1.Controls.Add(rb); } }