一个panel中动态生成一些radio和一个textbox。
初始化的时候动态给radio加事件 使得切换radio时一当某个radio被选中,下面的textbox立刻显示该radio的text值
do u understand what i mean..........

解决方案 »

  1.   

    radioButton1.CheckedChanged += new EventHandler(radioButton1_CheckedChanged);void radioButton1_CheckedChanged(object sender, EventArgs e)
            {
                throw new Exception("The method or operation is not implemented.");
            }
      

  2.   

         int x = 0;
                int width = 6;
                int hang = 1;
     CheckBox ckb=null;
                foreach (string item in strList)
                {
                    if (width > 308)
                    {
                        hang += 10;
                        width = 6;
                    }
                     ckb = new CheckBox();
                    ckb.Text =item;
                    ckb.Location = new System.Drawing.Point(width, 2 * hang);
                    ckb.CheckedChanged += new EventHandler(ckb_CheckedChanged);
                    x = ckb.Text.Length;
                    ckb.Size = new System.Drawing.Size(x * 13 + 18, 16);
                    width = ckb.Location.X + ckb.Size.Width + 10;
                    pnlChildBox.Controls.Add(ckb);            }       void ckb_CheckedChanged(object sender, EventArgs e)
            {
     CheckBox rbt= (CheckBox )sender;
    textbox=rbt.text;
          }这是动态创建CheckBox 的,,楼主稍微改下就可以了。
      

  3.   

    函数里面的sender强制转换为radiobutton,提取他的text就可以了
      

  4.   

    初始化的时候给radio加Id,切换的时候根据Id决定绑定的事件和radio的text值.