Solved

Help with Panel.Controls.Contains?

Posted on 2002-07-25
4
477 Views
Last Modified: 2008-03-04
How can I deturmine of a Panel contains a form?
0
Comment
Question by:eeevbeee
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 60 total points
ID: 7178163
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
 

Author Comment

by:eeevbeee
ID: 7178468
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
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7179724
I am not a VB person.. but i will give it a shot :-)
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9421019
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

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now