清除Windows窗体中的复选框 [英] clearing checkbox in windows form
本文介绍了清除Windows窗体中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
foreach (Control ctrl in cc)
{
TextBox tb = ctrl as TextBox;
if (tb != null)
tb.Clear();
else
RecursiveClearTextBoxes(ctrl.Controls);
}
以上我用于重置文本框的代码,有人可以为我提供类似于checkbox
above code i''ve used for resetting textbox, can anybody help me with something similar to this for checkbox
推荐答案
的帮助吗?只需将"TextBox"替换为"CheckBox",将".Clear()"替换为".Checked = false"
我认为这是日常作业"吗?我似乎已经看过几次了……
If you have managed to do this for TextBoxes, then just replace "TextBox" with "CheckBox", and ".Clear()" with ".Checked = false"
I take it this is "homework of the day"? I seem to have seen this a couple of times already...
foreach (Control ctrl in cc)
{
checkbox cb = ctrl as checkbox;
if (cb != null)
cb.Checked = false;
else
RecursiveClearTextBoxes(ctrl.Controls);
}
您可以像上面一样使用as
,也可以像下面那样使用is
you can use as
like above or you can use is
like below
foreach (Control ctrl in cc)
{
if (cb is checkbox)
cb.Checked = false;
else
RecursiveClearTextBoxes(ctrl.Controls);
}
这篇关于清除Windows窗体中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文