Accessing variables instantiated by parent usercontrol

I have a form and 2 usercontrols
The form is just a container for the main user control.
The main usercontrol is basically just a tab control
In the codebehind for that usercontrol I have newed up a class
called DTOV  - so in this class I have  public UserControls.SureFire.Helpers.DTOV dtov = new Helpers.DTOV();
and I have a variable in that class called
public int IHaveUnclaimed {get;set;}
---------
In the Main usercontrol I have set that variable with a value and I want to access it in a child user control that is on a tab in the main usercontrol - how can I do that.  - I want to be able to access dtov.IHaveunclaimed
Is that possible?
LVL 6
r3nderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
You have tags for Winforms, but the description sounds like a web site issue, so I am confused.  The proper solution depends on the answer.
0
r3nderAuthor Commented:
Winforms
0
Bob LearnedCommented:
1) Is there a reason to split up the form into separate controls?  In my opinion, that just creates a level of complexity, and makes it more difficult to maintain the code.

2) You would need to get a reference to the parent control, in order to access the property.  You should be able to do that with the Parent property (it's been a while since I have worked with Windows Forms).
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

r3nderAuthor Commented:
I tried Form parent = (Form) this.parent;
but that didny wprk
parent was null (event though it is just a usercontrol and not a form)
0
Bob LearnedCommented:
How are you adding the user control to the form?  You might need to set Parent explicitly.
0
r3nderAuthor Commented:
forms.Popup pu = new popup();
Usercontrols.MyUsercontrol uc = new MyUsercontrol();
pu.Width = uc.width;
pu.Height = uc.height;
ou.text = "My Title";
pu.Controls.Add(uc);
0
Bob LearnedCommented:
Try adding this line:

uc.Parent = pu;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
r3nderAuthor Commented:
Thanks Bob
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.