有没有在分组框中的任何财产,表明嵌套控件进行了检查? [英] Is there any property in the GroupBox that indicates that nested controls were checked?

查看:112
本文介绍了有没有在分组框中的任何财产,表明嵌套控件进行了检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯使用GroupBox控件在我的窗体页(的WinForms)。

Im using GroupBox Control on my Form Page(WinForms).

组框包含五个控件(单选按钮)。

The GroupBox contain five controls(RadioButtons).

如果组框控件包含属性,inidactes如果任何控件内的按钮进行了检查任何想法?

Any idea if group box control contains property that inidactes if any of the button inside the control were checked?

推荐答案

没有因为GroupBoxes并不意味着只是单选按钮。它是一种通用集装箱的控制。要检查什么被选中,你可以做一个符合的LINQ

No since GroupBoxes are not meant for just RadioButtons. Its a general container control. To check if anything is checked, you could do in one line with Linq.

bool anyChecked = gb.Controls.OfType<RadioButton>().Any(rb => rb.Checked);

或者你可以用它创建自己的扩展方法,方便地调用它如果经常重复使用。

Or you could create your own extension method with it and call it easily if its often re-used.

这篇关于有没有在分组框中的任何财产,表明嵌套控件进行了检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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