回 帖 发 新 帖 刷新版面

主题:[讨论]菜鸟问题,求高手帮解一下

        private void button1_Click(object sender, EventArgs e)
        {
           if(this.radioButton1.Checked==true){
               MessageBox.Show(this.radioButton1.Text,"",MessageBoxButtons.OK);
           }
           else if (this.radioButton2.Checked == true)
           {
                MessageBox.Show(this.radioButton2.Text,"",MessageBoxButtons.OK);
           }else{
               MessageBox.Show(this.radioButton3.Text, "", MessageBoxButtons.OK);
           }
        }

点击保存时消息框提示单项选择所选择的项,三个我能判断Checked属性为true,但是万一有一百个要怎么去得到所选择的项呢,怎么循环?

回复列表 (共1个回复)

沙发


private void radioButton_Click(object sender, EventArgs e)
        {
              radioButton rb=(radioButtonn)sender;
              
           MassageBox.Show(rb.Text,"",MessageBoxButtons.OK);
         }

选中所有的radioButton,设置他们选中的事件为同一个,即上面的那个。


我来回复

您尚未登录,请登录后再回复。点此登录或注册