且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

清除Windows窗体中的复选框

更新时间:2023-12-06 11:28:22

的帮助吗?只需将"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);
}