By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,877 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

Accessing public sub in MdiParent form

P: n/a
My project uses a MDI parent form and several child forms. I need to call a
public sub in the parent form (which is also the startup object) from one of
the child forms in order to change the appearance of the toolbar under
certain conditions. So far I have not figured out how to reference the sub
from another form.

One member of this group suggested I use the statement:
CType(Me.Owner, frmMain).tbMainReset()

where "tbMainReset" is a public sub in the parent form. However, running
this statement gives me the error: "Object reference not set to an instance
of an object."

Thanks for any advice.
Steve Enzer
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Steve Enzer" <en***@frontiernet.net> schrieb:
My project uses a MDI parent form and several child forms. I need to call
a public sub in the parent form (which is also the startup object) from
one of the child forms in order to change the appearance of the toolbar
under certain conditions. So far I have not figured out how to reference
the sub from another form.

One member of this group suggested I use the statement:
CType(Me.Owner, frmMain).tbMainReset()


This solution is close to the /real/ solution. Simply use the 'MdiParent'
property instead of the 'Owener' property:

\\\
DirectCast(Me.MdiParent, MainForm).ResetMainToolBar()
///

Note that you have to set the MDI child's 'MdiParent' property to the MDI
container form, which is pretty obvious and required in order to show a form
as an MDI child.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
This works great! Thank you very much for your help.
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.