简体   繁体   English

我该怎么办才能选择一个复选框?

[英]How can I do so only one checkbox can be selected?

How can I do so only one box can be selected at the same time? 我怎么能这样做只能同时选择一个盒子?

foreach (var i in contestlist)
{
    CheckBox cnb = new CheckBox();
    cnb.Text = i.Name;
    cnb.Location = new Point(10, panel1.Controls.Count * 20);
    panel1.Controls.Add(cnb);
}

If you only want one selected then the case is you want to use radiobuttons instead 如果您只想选择一个,那么您希望使用单选按钮

If you put radio buttons into a groupbox you can make it so only one can be selected within each groupbox 如果将单选按钮放入组合框中,则可以将其设置为在每个组框中只能选择一个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以一种形式使用多个单选按钮和多个组,以便每行和每列只能选择 1 个按钮? - How would I use multiple radio buttons and multiple groups in one form so that only 1 button per row and column can be selected? 如何获得类似单选按钮组的行为,以便只能选择一项 - How to get behavior like a radio button group so only one item can be selected "只能选择一个复选框" - Only one checkbox to be selected 我怎样才能使我的 class 变量只能设置为三个选项之一? - How can I make it so my class variables can only be set to one of three choices? 当使用.net MVC RadioButtonFor()时,如何分组以便只能进行一次选择? - When using .net MVC RadioButtonFor(), how do you group so only one selection can be made? 如何将 datagridview 的选定行(带复选框)发送到数据表? - how can I send selected rows(with checkbox ) of datagridview to datatable? 只能有一个“页面”指令-如何解决此问题? - There can only be one 'page' directive - How do I fix this? 如何做到这一点,使我的字段只设置一​​次? - How can I make it so my field is only set the one time? 如何编辑序列,使其仅使用LINQ返回一个元素 - How can I edit my sequence so it returns one element only using LINQ 如何创建“自定义属性”,以便仅将其应用于“虚拟”方法? - How do I create a “Custom Attribute” so that it can only be applied to “virtual” methods?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM