DevPinoy.org
A Filipino Developers Community
ATTENTION:Take our Code Challenge for the month of October 2008 and win some great prize! Learn more about it here!

System.Windows.Forms.Control$ControlCollection class

I tried to use the ControlCollection class defined inside the System.Windows.Forms.Control to use as temporary storage of layout-affected controls in my last post.  Not knowing the internals of the said class, I got some problems when child controls of the container control are not added to my instance of ControlCollection after invoking the Add method.

Note that the default and only constructor of ControlCollection takes a Control instance as its owner.  Since I don’t want to mess up the original ControlCollection of my container control, I just passed the container control as the parameter to the constructor.  Upon looking at the disassembled code for the ControlCollection class, I was surprise that there is a handle if the control being added is already parented and its parent is the same as the owner of the ControlCollection instance being added to:

[code language="C#"]
if (value.parent == this.owner)
{
    value.SendToBack();
}
[/code]

Now this is the handler that I was seeking before when I tried to re-add controls already existing in the ControlCollection without getting any exceptions.

Posted Mar 04 2005, 06:18 PM by jokiz
Filed under: , ,

Comments

Ephedra products. wrote Ephedra.
on 04-12-2008 11:41 PM

Connecticut ephedra lawyers. Ephedra.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Enter the numbers above:

Copyright DevPinoy 2005-2008
Powered by Community Server (Commercial Edition), by Telligent Systems