MDI; Finding a property on parent from MDI child form
-
Hi, I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from. I want too use the mousedown event on a child frmShow to draw lines on the form if the radPoly was clicked on the pnlTools on the parent MDI form. Please help with a simple code example. Thanks Ian
-
Hi, I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from. I want too use the mousedown event on a child frmShow to draw lines on the form if the radPoly was clicked on the pnlTools on the parent MDI form. Please help with a simple code example. Thanks Ian
Ian, It isn't a real simple example, but you could take a look at my Extensions to DrawTools[^] article which has the type of ability (and more) you are looking for. In that application, the MDI parent form sets properties on the
DrawArea
object to communicate settings from parent to child. HTHSincerely, -Mark mark@msdcweb.com http://www.msdcweb.com
-
Hi, I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from. I want too use the mousedown event on a child frmShow to draw lines on the form if the radPoly was clicked on the pnlTools on the parent MDI form. Please help with a simple code example. Thanks Ian
ianhunt01 wrote:
I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from.
Why? Best Practice would be for views to get their data from the Model rather than another View. See Model-View-Controller[^]
led mike
-
ianhunt01 wrote:
I have got a MDI app where one of the childforms must be able to see the status of a RadioButton on a docked panel on the MDI from.
Why? Best Practice would be for views to get their data from the Model rather than another View. See Model-View-Controller[^]
led mike
-
Ian, It isn't a real simple example, but you could take a look at my Extensions to DrawTools[^] article which has the type of ability (and more) you are looking for. In that application, the MDI parent form sets properties on the
DrawArea
object to communicate settings from parent to child. HTHSincerely, -Mark mark@msdcweb.com http://www.msdcweb.com
-
No, I had a look at the Wiki and it does not tell me much in a practical way of achieving this. But thanks in any case Ian
-
Thanks Mark, Nice app and very usefull info for something else that I want to do but no MDI stuff in there ? cheers Ian
Ian, The DrawTools project uses a MDI parent form - I had forgotten it doesn't use any child forms. Try this out for a solution to your problem: In your child form expose some
public
orinternal
properties that are set when a toolbar button in the parent form is clicked. For example: *** child form ***public bool isPoly;
*** parent form *** In thetoolbarButton_Click(...)
event:if (ActiveMdiChild == null) return;
var child = ActiveMdiChild as childformclass;
child.isPoly = toolbarButton.Checked;This way the child form(s) can see when a button on the toolbar in the parent is checked or not and react accordingly. Additionally in the parent form you will want to react when the child form changes and set the state of buttons according to the active child form: *** parent form *** In
MdiChildActivate
event:if (ActiveMdiChild == null) return;
var child = ActiveMdiChild as childformclass;
toolbarButton.Checked = child.isPoly;HTH
Sincerely, -Mark mark@msdcweb.com http://www.msdcweb.com
-
Ian, The DrawTools project uses a MDI parent form - I had forgotten it doesn't use any child forms. Try this out for a solution to your problem: In your child form expose some
public
orinternal
properties that are set when a toolbar button in the parent form is clicked. For example: *** child form ***public bool isPoly;
*** parent form *** In thetoolbarButton_Click(...)
event:if (ActiveMdiChild == null) return;
var child = ActiveMdiChild as childformclass;
child.isPoly = toolbarButton.Checked;This way the child form(s) can see when a button on the toolbar in the parent is checked or not and react accordingly. Additionally in the parent form you will want to react when the child form changes and set the state of buttons according to the active child form: *** parent form *** In
MdiChildActivate
event:if (ActiveMdiChild == null) return;
var child = ActiveMdiChild as childformclass;
toolbarButton.Checked = child.isPoly;HTH
Sincerely, -Mark mark@msdcweb.com http://www.msdcweb.com
Thanks Mark, This was really helpfull !! I used to work in VB6 Pro and thought about moving over to C#.Net instead of VB.Net. In order to learn the new C#.Net environment it seems you have to buy a lot of books (four up to date) and do the Microsoft certified courses and still all of it only shows you bits and pieces and end up becoming very expensive. So what I am trying to say is that the code you supplied helps me a lot in grasping whats happening. So thanks again for your patience. Ian
-
Thanks Mark, This was really helpfull !! I used to work in VB6 Pro and thought about moving over to C#.Net instead of VB.Net. In order to learn the new C#.Net environment it seems you have to buy a lot of books (four up to date) and do the Microsoft certified courses and still all of it only shows you bits and pieces and end up becoming very expensive. So what I am trying to say is that the code you supplied helps me a lot in grasping whats happening. So thanks again for your patience. Ian
Ian, You are very welcome - glad I was able to help. I came to C# after making a living programming in Visual FoxPro for close to 10 years. I picked up some Java experience along the way as well. When I started learning .NET and C# I too bought several books - the best one for me was Windows Forms 2.0 Programming[^]. Hang in there and don't be afraid to ask questions on CodeProject - everyone here is very helpful.
Sincerely, -Mark mamiller@rhsnet.org
-
Ian, You are very welcome - glad I was able to help. I came to C# after making a living programming in Visual FoxPro for close to 10 years. I picked up some Java experience along the way as well. When I started learning .NET and C# I too bought several books - the best one for me was Windows Forms 2.0 Programming[^]. Hang in there and don't be afraid to ask questions on CodeProject - everyone here is very helpful.
Sincerely, -Mark mamiller@rhsnet.org