Solved

Checking if a control exists within a container control?

Posted on 2013-11-14
6
353 Views
Last Modified: 2013-11-14
I have a routine that changes various properties of controls. Within this routine, I need to check each control that is passed into it whether or not they are contained within a control. I'm sure this can be done but I've never done it before and don't know how to check for it.

Thanks!
0
Comment
Question by:BlakeMcKenna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 39648896
What issue(s) are you having with controls that are not contained by something?...we need more details to even begin to help with this one as it's too vague.
0
 

Author Comment

by:BlakeMcKenna
ID: 39649037
I'm trying to set the background color of a control that resides within a container control to the container control's background color.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 39649097
Well, that would be difficult to do if said control doesn't have a container!  =)

You can check the Parent() property to see if it has a value.  It it is Nothing, then no container is set:
        If Not IsNothing(ctl.Parent) Then
            ' ... control has a container ...
        Else
            ' ... control does NOT have a container ...
        End If

Open in new window

0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:BlakeMcKenna
ID: 39649345
Ok,

With the above code, how can I extract the Parent's BackColor or DefaultBackColor value?
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 39649500
?...Control.Parent() returns type Control.  Just access it!

Assuming it is not Nothing:
ctl.BackColor = ctl.Parent.BackColor

Open in new window

0
 

Author Closing Comment

by:BlakeMcKenna
ID: 39649570
Thanks...that worked!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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