-
Jul 9th, 2013, 02:54 PM
#1
Thread Starter
Hyperactive Member
How to call sub in MDI child form from MDI parent toolbar?
I created a few toolbars in parent form.
How to call sub in MDI child form from MDI parent toolbar?
-
Jul 9th, 2013, 03:07 PM
#2
Re: How to call sub in MDI child form from MDI parent toolbar?
The MDI parent will need to hold a reference to the created child.
-
Jul 9th, 2013, 08:33 PM
#3
Re: How to call sub in MDI child form from MDI parent toolbar?
There are a few ways that you can handle this. As ident says, if the parent form wants to affect the child form then it must have a reference to it, which goes for all objects. You could declare a member variable and assign the child form to it when you create it and then always use that variable. Alternatively, you can use the MdiChildren property, which is a collection of all the child forms. You can use a loop or a LINQ query to get the desired child by appropriate criteria.
There is another alternative though, which is the "professional" way to use MDI. Instead of creating the tool bar in the parent form, you create in the child form. That way, all the code goes in the child. You then use the merging functionality of the ToolStrip class to make the tool bar appear in the parent at run time. As far as the user is concerned, the tool bar is part of the parent but, as far as the code is concerned, it's part of the child. You get the best of both worlds.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|