Help with Panel.Controls.Contains?

How can I deturmine of a Panel contains a form?
eeevbeeeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
naveenkohliConnect With a Mentor Commented:
You can always traverse any control to check for presence of any kind of control.....


if (null != GetFormCtl(panelCtl))
{
 /* Has Form */
}

private Form GetFormCtl(Control parentCtl)
{
 if (prentCtl is Form)
 {
    return (Form)parentCtl;
 }
 Control ctl = null;
 int nCount = parentCtl.Controls.Count;
 for (int i = 0; i < nCount; i++)
 {
   ctl = GetFormCtl(parentCtl.Controls[i];
   if(ctl is Form)
   {  
     break;
   }
 }
 return (Form)ctl;
}
0
 
eeevbeeeAuthor Commented:
This looks very good, only I can't make out much since I don't speak C# or C++ only VB. Anyway you can do this in VB??


thanks

0
 
naveenkohliCommented:
I am not a VB person.. but i will give it a shot :-)
0
 
Bob LearnedCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by naveenkohli

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.