StrataFrame Forum

What is the ParentContainer property?

http://forum.strataframe.net/Topic5613.aspx

By Greg McGuffey - 1/5/2007

I'm attempting to write some code that will add controls to a form dynamically at runtime and when I look at the Designer file to see what is generated by the designer, for the SF controls, the ParentContainer property is set. E.g.





' This code is in the designer.

myTextBox.ParentContainer = Me.





Now, what has me confused is that this is set even when the control is added to a container, like a flowlayoutcontainer or tablelayoutcontainer or panel, etc. What is this property and why is it set to the form?



(So I don't break anything tooo badly:blinkSmile
By Trent L. Taylor - 1/5/2007

What is this property and why is it set to the form?

This is used as a synchronization object within the controls.  Since the container and the form will be operating on the same thread this is never going to be an issue.  To get the direct parent of any object you only need to reference the control like this:

MyControl.Parent

The ParentContainer property ties in with the ISynchronizeInvoke interface and properly working with delegates and threads.