How can I tell if a control can contain other controls?

Omid Golban

Member
Joined
Jun 3, 2003
Messages
6
Hello all,

I want to loop through the controls and change some settings for certain types of controls. So I loop through Me.Controls, but then
this can have other controls that can contain other controls. The only way I know how to check this is:
If Me.Controls(i).GetType Is GetType(System.Windows.Forms.TabControl) ....

Using the above method, Id have to check for Tab controls, panels, etc. Tab controls themselves contain tab pages which in turn
contain other controls.

Is there any way of checking if a control can contain other controls without hard coding it like above? I.e. something like:
If Me.Controls(i).May_Contain_Other_Controls ....

Thank you,
Omid
 
All controls can be the parent to other controls, so no special checking
should be necessary. Just looks at the Controls collection of all the
controls on the form, and look at the Controls collection of each of
those controls; all objects that derive from the Control class have
one.
 
Back
Top