c# radiobutton

wisdomone1發表於2012-03-03

private void button1_Click(object sender, EventArgs e)
        {

           //學習checkbox
            //checkbox是否選中標誌checkstate
            checkBox1.CheckState = CheckState.Checked;
            MessageBox.Show("checkbox當前狀態"+checkBox1.CheckState);

            //
            if (radioButton1.Checked==true)
            {
                //當選中radiobutton
                MessageBox.Show("選中了radiobutton1");
            }
        }


        //checkbox_checkstatechanged 事件表示checkbox狀態變動事件
        private void Form1_Load(object sender, EventArgs e)
        {
            checkBox1.CheckState = CheckState.Unchecked;
            MessageBox.Show("checkbox未選中");
  
        }

        //radiobutton狀態變化事件
        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            MessageBox.Show("radiobutton1當前狀態為"+ radioButton1.Checked);
        }

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-717578/,如需轉載,請註明出處,否則將追究法律責任。

相關文章