Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Accessing MDI Parent variable values from MDI child


Reply
 
Thread Tools Display Modes
  #1  
Old 08-04-2012, 08:27 PM
celtic celtic is offline
Centurion
 
Join Date: Mar 2009
Posts: 129
Default Accessing MDI Parent variable values from MDI child


Hi all.

I'm wondering how to go about accessing the value of variables in an MDI parent form from a child form.

I can for example, access the text propery of a text box on the parent from the child just by specifying the parent's form name, but not the value of a variable even though it is declared public.

The specific variable is an instance of a class, and the members of the class are unavailable from the child even though the class is instantiated in a publc variable in the parent.
Reply With Quote
  #2  
Old 08-04-2012, 08:53 PM
AtmaWeapon's Avatar
AtmaWeapon AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,416
Default

The property that gets you the parent returns a value of type Form, but you know it's a more specific type. When this happens, you have to cast. For example, say your parent form is called "BigForm". Also let's assume the property is MdiParent because I can't remember what it is. You'd write something like this:
Code:
Dim parent As BigForm = CType(Me.MdiParent, BigForm)
Dim value = parent.PropertyName
Also, assume "PropertyName" is the name of the property you wanted to access.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #3  
Old 08-06-2012, 07:45 PM
celtic celtic is offline
Centurion
 
Join Date: Mar 2009
Posts: 129
Default

Ah. OK.
Thank you AtmaWeapon!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->