Radiobuttons as a group in different panels(单选按钮作为不同面板中的一个组)
问题描述
我正在使用 C# 开发 WindowsForms 应用程序.我创建了一个带有一些面板的表单.每个面板都有一个 RadioButton.当我点击一个 RadioButton,然后点击另一个,两者都被选中.
I'm using C# to develop WindowsForms application. I have created a form with some panels. Each panel has a RadioButton. When I click a RadioButton, and then other one, both are checked.
如何模拟所有RadioButtons都在同一个组中,所以只能勾选一个,其他不勾选?
How could I simulate that all the RadioButtons are in the same group, so only one can be checked, and the others are unchecked?
当然,我可以控制每个RadioButton的checkedChanged事件……但是有没有更好的解决方案?
Of course, I can control the checkedChanged event for each RadioButton ... but is there any better solution?
提前致谢.
推荐答案
如果 RadioButtons 在同一个父级中,它们会自动链接.由于您希望它们存在于不同的容器中,因此您必须手动链接它们.
RadioButtons are automatically linked if they are inside the same parent. Since you want them to live in different containers you will have to link them manually.
这篇关于单选按钮作为不同面板中的一个组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:单选按钮作为不同面板中的一个组
基础教程推荐
- C# 9 新特性——record的相关总结 2023-04-03
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 如果条件可以为空 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 将数据集转换为列表 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
