Part of the problem is that you can't change a list while enumerating
through it.
So for example:
For Each Child as guiControlBase in SomeControl.Children
SomeControl.RemoveChild(Child)
Next
Will not work, because when it hits the "next", the SomeControl.Children
list has been modified. This actually throws an exception, and I'll bet the
exception is being written to the EEGUI Debug log file...
There are two ways to work around this...
If you are wanting to remove just ONE child, based on something like a
TagID, you could do this:
For Each Child as guiControlBase in SomeControl.Children
If Child.TagID = MyParameter Then
SomeControl.RemoveChild(Child)
Exit For
End If
Next
This exits the For loop when a successful match is found... so you remove
from the list, but don't attempt to go farther THROUGH the list, thus
avoiding the problem.
Otherwise, you should do a While loop, and RemoveAt index 0 each time until
children.count = 0
While SomeControl.Children.Count > 0
SomeControl.RemoveChild(SomeControl.Children(0))
End While
This is not iterating through a collection... it's merely checking the
number of children in the list each time through. Thus, you can keep
removing form it until there are 0 children left. As long as there are
children left, it will remove the "first child in the list"...
No virus found in this incoming message.
Checked by AVG -
http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1677 - Release Date: 9/17/2008
5:07 PM