RadioButton的使用

VS2005 RadioButton的使用

1. 共有IDC_RADIO1、IDC_RADIO2、IDC_RADIO3、IDC_RADIO4四个Button;想把前两个分到一组,后两个分到一组;方法:

把IDC_RADIO1的Group propety设为true,把IDC_RADIO2的Group propety设为false;

把IDC_RADIO3的Group propety设为true,把IDC_RADIO4的Group propety设为false。

这样每组中每次只能有一个button被选中。

2. 获取到被选中的button,方法:

GetCheckedRadioButton(IDC_RADIO1, IDC_RADIO2)==IDC_RADIO1   IDC_RADIO1被选中;

GetCheckedRadioButton(IDC_RADIO3, IDC_RADIO4)==IDC_RADIO4   IDC_RADIO4被选中;


VS2012 RadioButton的使用

XAML如下

    <StackPanel>
        <RadioButton GroupName="colorgrp">Red</RadioButton>
        <RadioButton GroupName="colorgrp">Blue</RadioButton>
        <RadioButton GroupName="numgrp">1</RadioButton>
        <RadioButton GroupName="numgrp">2</RadioButton>
        <RadioButton>4</RadioButton>
        <RadioButton>5</RadioButton>
    </StackPanel>

在一个Panel下,若没有指定GroupName则为一组,指定了GroupName为另外一组.

逻辑:一组内,选中一个Button取消其他的Button选中状态.


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值