溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

獲取C# RadioButton選中值

發(fā)布時(shí)間:2020-08-10 20:05:19 來(lái)源:網(wǎng)絡(luò) 閱讀:12323 作者:qianyuqianyuan 欄目:軟件技術(shù)

  C# RadioButton的一些屬性介紹

 

    1.C# RadioButton只允許用戶從幾個(gè)選項(xiàng)中選擇一個(gè),同一個(gè)容器中一次只能選擇一個(gè)按鈕;

    2.C# RadioButton的Appearance屬性:根據(jù)的以下兩種取值控制外觀:
    Normal:圓圈+標(biāo)簽,選中后會(huì)填充圓圈;
    Button:按鈕,類似于開關(guān),選中后按下,未選中時(shí)凸起;

    3.C# RadioButton的Checked屬性:
    true:選中;
    false: 未選中;
    4.C# RadioButton的CheckedAlign屬性:確定圓圈與標(biāo)簽文本的相對(duì)位置。

 

  1. private void button1_Click(object sender, EventArgs e)  
  2.         {  
  3.             string checkedRBName = "";  
  4.               
  5.             //取得選中單選按鈕的名稱  
  6.             if (radioButton1.Checked)  
  7.             {  
  8.                 checkedRBName = radioButton1.Name;  
  9.             }  
  10.             else if (radioButton2.Checked)  
  11.             {  
  12.                 checkedRBName = radioButton2.Name;  
  13. //獲得和radioButton按鈕對(duì)應(yīng)標(biāo)簽的內(nèi)容,用的是 radioButton2.Text屬性;  
     
  14.             }  
  15.             else 
  16.             {  
  17.                 checkedRBName = radioButton3.Name;  
  18.             }  
  19.             MessageBox.Show(checkedRBName + " was checked.");  
  20.         }  
  21. 原文:http://www.csharpwin.com/csharpspace/3911r2169.shtml
     

 

 

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI