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