in my software I have a TabControl
and I want to search for all Controls
of a certain type using foreach
(for example) and change some of there properties. Now when I do something like this:
Control ctrl;
ctrl = My_CheckedListBox;
((CheckedListBox)ctrl).SetItemChecked(0, true);
It works fine, no problem. But when I use foreach it doesn't:
foreach (Control item in ModuleTab.Controls)
{
if (item is CheckedListBox)
{
for (int i = 0; i < ((CheckedListBox)item).Items.Count; i++)
{
((CheckedListBox)item).SetItemChecked(i, false);
}
}
}
I know it is because item
is not really the Control
but an object. I wonder if there is something like:
foreach (Control ref item in ModuleTab.Controls)
Any help?
Aucun commentaire:
Enregistrer un commentaire