C# 中关于radiobutton控件的使用


在一个Form窗口中定义了3个radiobutton,radioButton1、radioButton2和radioButton3,以及button1和button2(这里可以是其他控件)

为了实现单击radioButton1时,button1显示"A1",button2显示"A2";

单击radioButton2时,button1显示"B1",button2显示"B2";

单击radioButton3时,button1显示"C1",button2显示"C2".

下面代码就可以实现这个功能:

private void radioButton1_CheckedChanged(object sender, EventArgs e) 
{
    if(radioButton1.Checked == true)
    {
        button1.Text == "A1";
        button2.Text == "A2";
    }
    if(radioButton2.Checked == true)
    {
        button1.Text == "B1";
        button2.Text == "B2";
    }
    if(radioButton3.Checked == true)
    {
        button1.Text == "C1";
        button2.Text == "C2";
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM