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.
这篇关于单选按钮作为不同面板中的一个组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:单选按钮作为不同面板中的一个组
基础教程推荐
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
