How to Access function/property of the form from MDI form

RonDun

New member
Joined
Jan 19, 2009
Messages
2
Programming Experience
Beginner
Hi Experts, I'm a newbie in VB.net 2008 just need some help on how can I call the function/property of a form using my toolbar button on the MDI Form.

Because I have a plan to create an MDI form with Multiple form, and the toolbar button on my MDI form can easyly call the Function/Property of every form I will create.

Example
I have From1 and Form2 with same Function(Add New, Edit, Delete, Undo, etc.), then in my MDI form I have the active form and it's either Form1 or Form2. When I Click the Button New on the Toolbar of my MDI Form the textbox in my Form1 or Form2 who ever is active it will Enable the Textbox and buttons on the form, and if I click the UNDO button it will Disable the Textbox and buttons.

In VB 6 I have seen a command like this:

Screen.Activeform.<Function/Property name>

but when I try this in VB.Net 2008 It's different and I got error message.

Can any of me help me out?

Thanks in Advance

Ronald
 
If you have Option Strict Off, which it is by default, then you can still do that in VB.NET, although the property would be ActiveMdiChild. That said, although it makes certain things easier, I don't recommend having Option Strict Off and using late-binding. There is more than one "proper" way to do this:

1. Create a base form that defines all the common members, then derive all your child forms from that common base class. They can each override the common members and implement them in their own way. In the parent form you cast ActiveMdiChild as the common base type and then call the desired methos using early binding.

2. Put all your menu items and tool bar buttons in each of the child forms and then use the merging functionality of the ToolStrip control to display them in the parent. That way the user will see the same menus and tool bars in the parent no matter which child is active, but they will actually be different objects that are members of the child forms themselves. Another advantage of this is that different items can be added for each child and the parent won't need complex logic to decide what to show and what to hide.
 
@jmcilhinney

Thanks for the response. That's what I want to do with my program, but can you give me a simple program so that I can analyze it and fully understand how to do it.

I can do this in Visual FoxPro 8 because I'm a FoxPro programmer, now I'm migrating to VB.Net and I want to convert my program written in FoxPro to VB.Net 2008.

I hope you can help me in my advancement in programming.

Thanks

Ronald
 
Back
Top