单选按钮作为不同面板中的一个组 [英] Radiobuttons as a group in different panels

查看:19
本文介绍了单选按钮作为不同面板中的一个组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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.

这篇关于单选按钮作为不同面板中的一个组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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