iT邦幫忙

0

Day 24視窗應用程式進階控制: LinkLabel(連結標籤)& RadioButton(單選按鈕)

c#
  • 分享至 

  • xImage
  •  

LinkLabel(連結標籤)
1.什麼是 LinkLabel
LinkLabel是一種可在Windows Form應用程式中顯示「可點擊文字連結」的控制項
它的外觀類似一般的 Label,但支援點擊事件,可用來:

  • 開啟網頁連結
  • 啟動電子郵件
  • 導向應用程式內其他表單或功能
    可以想像成「可以點的文字 Label」

2.常見用途

  • 點擊後開啟網站(例如導向學校首頁或官方網站)
  • 開啟使用者的預設電子郵件應用程式
  • 切換表單或顯示幫助文件
  • 在程式中觸發某個動作(像是登入說明、關於視窗)

3.常用屬性(Properties)
https://ithelp.ithome.com.tw/upload/images/20251009/20178925s7Ti3qJlMS.png

4.常用事件(Events)
LinkClicked 當使用者點擊連結文字時觸發

範例
控制項配置
https://ithelp.ithome.com.tw/upload/images/20251009/20178925TdAprGIMrU.png

程式碼
https://ithelp.ithome.com.tw/upload/images/20251009/20178925yXaETnSsJL.png

點擊畫面網址跳出網址頁面
https://ithelp.ithome.com.tw/upload/images/20251009/201789258T2ShLCdpH.png

RadioButton(單選按鈕)
1.什麼是 RadioButton
RadioButton(單選按鈕)是一種讓使用者在多個選項中只能選擇一個的控制項
當一組RadioButton被放在同一個容器(例如 Form、Panel、GroupBox)中時,同一組裡只能有一個被選取
常用在問卷、設定選項、性別選擇、付款方式等情境

2.常見用途

  • 性別選擇(男 / 女)
  • 付款方式(信用卡 / 現金 / 行動支付)
  • 難易度設定(簡單 / 普通 / 困難)
  • 主題風格切換(亮色 / 暗色)

3.常用屬性(Properties)
https://ithelp.ithome.com.tw/upload/images/20251009/20178925Rdq5MbuG26.png

4.常用事件(Events)
CheckedChanged 當選取狀態改變(從未選到選取,或反之)時觸發

範例
控制項配置
https://ithelp.ithome.com.tw/upload/images/20251010/20178925GuZv3TMKBT.png

程式碼
https://ithelp.ithome.com.tw/upload/images/20251010/20178925ZlUeV5jTyo.png

選擇"男"按鈕,按下"顯示選擇結果"按鈕顯示文字
https://ithelp.ithome.com.tw/upload/images/20251010/20178925vFMwy26su3.png

選擇"女"按鈕,按下"顯示選擇結果"按鈕顯示文字
https://ithelp.ithome.com.tw/upload/images/20251010/20178925g5j0p3n9E7.png


圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言