473,320 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

parent / child form w/ menu

I have a parent form that has a menu. I then have a child form on the
menu. From the child form I need to change the parent form's menu - how
can i do that? I tried me.parent.mfavorites, but that doesn't exist (the
menu name is mfavorites).

Thanks.

Darin

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #1
7 1808
"Darin" <darin_nospam@nospameverschrieb
I have a parent form that has a menu. I then have a child form on
the menu. From the child form I need to change the parent form's
menu - how can i do that? I tried me.parent.mfavorites, but that
doesn't exist (the menu name is mfavorites).
Yes, it doesn't exist because every Form can be the parent of the child
form. Not every parent has that property. If you know that the parent is
always of type ParentForm, you can cast to that type (use DirectCast). If
you want to write reusable code, depending on the situation, I'd probably
raise an event in the child form, caught by the parent form.
Armin

Jun 27 '08 #2
Well, i don't quite understand the direct cast, so let's look at the
raiseevent.

My parent form is in an EXE that is a stand alone - the child is in a
DLL, so the two forms (fUTStart in EXE and fUTMenu in DLL) can't
actually see each other.

Not sure how i can raise an event on the parent form w/o the two forms
really "knowing" about each other.

Darin

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #3
On Wed, 25 Jun 2008 12:04:02 -0700, Darin <darin_nospam@nospamever>
wrote:
>Well, i don't quite understand the direct cast, so let's look at the
raiseevent.
If the parent form is an instance of class MyParentForm:
Dim myParent as MyParentForm = DirectCast(me.Parent, MyParentForm)
myParent.mfavorites. ...
This requires that the child form project have a reference to the main
form project.
>
My parent form is in an EXE that is a stand alone - the child is in a
DLL, so the two forms (fUTStart in EXE and fUTMenu in DLL) can't
actually see each other.
Just because the class definitions of two forms are in different
assemblies doesn't mean they can't 'see' each other, whatever you mean
by 'see'. If either assembly has a reference to the other, then you
can reference from one to the other.
>Not sure how i can raise an event on the parent form w/o the two forms
really "knowing" about each other.
You can't. The child project would need a reference to the parent
form project so it could raise the parent form's event.

Or you could define an Interface in a common assembly and have the
parent form Implement that interface, then both parent and child
projects would need to reference the project that defines the
Interface.
Jun 27 '08 #4
Jack,

No, the child form would raise an event and the parent form would handle the
event.

Using this technique the child form can be reused with any parent form,
since the child form does not need to know anything about the parent form.

Kerry Moorman
"Jack Jackson" wrote:
>
You can't. The child project would need a reference to the parent
form project so it could raise the parent form's event.
Jun 27 '08 #5
how does the child form raise an event on the parent form?
Darin

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #6
"Darin" <darin_nospam@nospameverschrieb
Well, i don't quite understand the direct cast, so let's look at the
raiseevent.

My parent form is in an EXE that is a stand alone - the child is in
a DLL, so the two forms (fUTStart in EXE and fUTMenu in DLL) can't
actually see each other.

Not sure how i can raise an event on the parent form w/o the two
forms really "knowing" about each other.
The parent Form knows the child Form, therefore it can handle the child's
events.
Armin

Jun 27 '08 #7
It doesn't. As Kerry pointed out, the child raises an event that it
defines. The parent subscribes to the child's event with AddHandler.

On Wed, 25 Jun 2008 14:46:55 -0700, Darin <darin_nospam@nospamever>
wrote:
>how does the child form raise an event on the parent form?
Darin

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jinu | last post by:
Hello, My application loads with a form which is the mdi parent and a menu item click (main menu of the parent form) brings up a child form. I have to wait for a considerable amout of time to...
2
by: Brindley | last post by:
Hi there, In my Mdi application, I have placed a set of controls on the parent form to call child forms. The problem is that the controls hide the child forms. I have used SendToBack when Im...
6
by: Tom | last post by:
Rather than merge child menus, I would like for some common functionality between various MDI child forms to process an event fired from the main menu, depending on who is in focus. Is this...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
0
by: jim | last post by:
I'm using Visual Studio 2005 and .Net 2.0. When I maximize my Child form, the title bar of the Child form will overtake the parent form's menu bar
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
4
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
2
by: Matt | last post by:
Ok here is my problem: I have a MDI parent form called "Main" that I declare in a public module when I start up my program. This form holds the drop down menu that allows my users to access all...
3
by: zacks | last post by:
Forgive me if this has been already asked an answered, I did do a search both here and in VS2005 Help, but I can't find the answer to my question. I am developing an MDI application that is a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.