-
October 30th, 2014, 02:02 PM
#1
how to send event from MDI window to child window
I have a simple question :
my project is two windows = main window + child window
I added button1 in main window
When I click in Butten1 I want to send this event to Child window to Draw Line in A Child Window...
Thanks in advance for helping.
-
November 2nd, 2014, 12:01 PM
#2
Re: how to send event from MDI window to child window
I hope to find answer to this question..
I am using VS 2008 and OS win7 64 Bit ...
I have a strong understanding for Win API programming but I am new for CS..
Many thanks in advance for your support..
-
November 3rd, 2014, 12:45 AM
#3
Re: how to send event from MDI window to child window
The simple way is to create an event in the main window which gets fired when you click the button. The child window would subscribe to the event and draw the line. Search bing or google for EventArgs examples.
That would be the easy way, but a better way (although more complicated) is to use MVC or MVVM design pattern. In general you want to try to avoid tight coupling between windows forms and using one of the design patterns is a good way to avoid it.
Essentially with the design patterns a form would not have any idea that there is a child form (or the child form doesn't know about its parent). With MVC, the view communicates with its controller and in MVVM the form communicates with the ViewModel. Using this approach it's easier to have a form used as a child in one form to be used as a form somewhere else. This is not so easy when the child depends on getting data (or operations) from a specific form (or parent of a parent form).
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
|