如何在复选框和单选按钮中设置组名 [英] How to set group name in check box and radio button

查看:188
本文介绍了如何在复选框和单选按钮中设置组名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

如何在复选框和单选按钮中设置组名.仅选择一项,则另一项将被取消选中.但同时获得两个项目将是选择模式.
仅复选框将处于选中和未选中模式. Windows应用程序中不会出现单选按钮.如何解决这个问题.

在此先感谢

Hello,

how to set group name in chek box and radio button. am selecting only one item then another item will be unchecked. but am getting both items will be selecting mode.
only check box will comes in checked and unchecked mode. radio button will not coming in windows application. how to solve this problem.

thanks in advance

推荐答案

使用RadioButton.GroupNameRadioButtonList控件.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobutton.groupname.aspx [ http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobuttonlist.aspx [ ^ ]


RadioButton控件可以显示文本和/或图像.当用户在组中选择一个选项按钮(也称为单选按钮)时,其他选项按钮将自动清除.给定容器(例如Form)中的所有RadioButton控件均组成一个组.要在一个表单上创建多个组,请将每个组放在自己的容器中,例如GroupBox或Panel控件.
参考: http://msdn.microsoft.com/en-us/library/system.windows.forms.radiobutton.aspx [ ^ ]

因此,如果要选择两个单选按钮,则必须将它们放在不同的容器中,例如面板或组框.
Use RadioButton.GroupName or RadioButtonList control.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobutton.groupname.aspx[^]
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobuttonlist.aspx[^]


The RadioButton control can display text, an Image, or both. When the user selects one option button (also known as a radio button) within a group, the others clear automatically. All RadioButton controls in a given container, such as a Form, constitute a group. To create multiple groups on one form, place each group in its own container, such as a GroupBox or Panel control.
Ref: http://msdn.microsoft.com/en-us/library/system.windows.forms.radiobutton.aspx[^]

So, if you want to select both the radiobutton then you have to put them on different containers like, panel or groupbox.


请看下面的链接.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobutton.groupname.aspx

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobuttonlist.aspx

但是首先请确保您要在Asp.Net/Windows中执行此操作.

对于Windows,请查看下面的链接.
http://msdn.microsoft.com/en-us/library/sefz7fxc.aspx
Have a look at below link.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobutton.groupname.aspx

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobuttonlist.aspx

But first make sure you want to do this in Asp.Net/Windows.

For Windows have a look at below link.
http://msdn.microsoft.com/en-us/library/sefz7fxc.aspx


使用checkboxlist和radiobuttonlist代替复选框/单选按钮,并提供组名以一次仅设置一个要检查的值.
Instead of checkbox/radio button use checkboxlist and radiobuttonlist and provide group name to set only one value to be checked at a time.


这篇关于如何在复选框和单选按钮中设置组名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆