[英]validation with RadioButton
I have 10 RadioButton inside a panel. 我在面板内有10个RadioButton。
I have 10 panels inside a tableLayoutPanel, Each one in different column. 我在tableLayoutPanel中有10个面板,每个面板在不同的列中。
How can i move between the columns and validate that in each column there is a selected radioButton? 我如何在列之间移动并验证每列中是否有选定的radioButton?
Thank you. 谢谢。
I have no experiences with the TableLayoutPanel
, but you could try this: 我没有使用
TableLayoutPanel
经验,但是您可以尝试以下方法:
bool allValid = true;
for(int c = 0; c < panel.ColumnCount; c++)
{
var colRadios = panel.Controls.OfType<RadioButton>()
.Where(rb => panel.GetColumn(rb) == c);
bool colValid = colRadios.Any(rb => rb.Checked);
if(!colValid)
{
allValid = false;
break;
}
}
( panel
is the TableLayoutPanel
) (
panel
是TableLayoutPanel
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.