Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign a loaded form to an object variable 1

Status
Not open for further replies.

JunglesMcBeef

Programmer
Sep 18, 2003
266
G'day,

I have a program that has a main form and many forms that are opened from the main form. Now, what I am trying to work out is if there is anyway to assign the main form to an object variable within one of those other forms, so I can work with the already loaded main form. I have been using Dim oMain as New frmMain but from my understanding wouldn't this create a completely new instance of that form? Also i'm wondering why the assignment above IS working, ie when I change a property of oMain, it changes the property of the Main form that is already loaded, even though oMain is a newly created instance. This is confusing me, so if someone can please clarify it for me I will appreciate it very much.
 
you should do this in the child window

Code:
public oMain as frmMain

and then this in the main window

Code:
dim ochild as new childform
ochild.omain = me
ochild.show

or this if tou use showdialog

child window

Code:
public omain as frmmain

and in the form load event

Code:
omain = me.owner

main window

Code:
dim ochild as new childform
ochild.showdialog(me)

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Ok, this requires a MDI container, say I didn't want my main form to be a MDI container, isn't there a way for this to be achieved? Also, is there any reason why it is currently working? I don't understand this, can someone please explain?
 
what I wrote doesn't require an mdicontainer.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Ahhh, sorry, I didn't understand that childform was actually representative of the form owned by the parent, not actually a ChildForm object type (if there is one?). Thanks heaps for that, much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top