环境:WinForm
条件:一个GroupBox中有3个RadioButton,有一个button,
只要我们选中哪个RadioButton,按一下我们就能获取它的值,并插入到数据库里,求代码

解决方案 »

  1.   

    RadioButton_Click事件里处理就行了。
      

  2.   

    没有测试,大概就是这个意思//鼠标点击事件获取3个RadioButton选中之一的Text值,三个都没有选中,为空字符串
    private void button_Click(object sender,EventArgs e)
    {
    string RadioButtonText = string.Empty;
    RadioButtonText = radioButton1.Checked?radioButton1.Text:radioButton2.Checked?radioButton2.Text:radioButton3.Checked?radioButton3.Text:String.Empty;}
      

  3.   

    radioButton_CheckedChanged(object sender,EventArgs e)
    {
     RadioButton rdb=sender as RadioButton;
    }
    RadioButton数组
    radioButton1.CheckedChanged += new EventHandler(radioButton_CheckedChanged);
    radioButton2.CheckedChanged += new EventHandler(radioButton_CheckedChanged);
      

  4.   

    button_click事件
    string text="";
    if(radioButton1.Checked==true){text=radioButton1.text;
    }else if(radioButton2.Checked==true){
    text=radioButton2.text;
    }else if(radioButton3.Checked==true){
    text=radioButton3.text;
    }