|
-
Mar 31st, 2009, 02:56 AM
#1
Thread Starter
Hyperactive Member
change a property of an item in MdiParent
hi all,
using a plugin architecture, i created a Form Class that holds the Mdi Form. it has menustrip, toolstrip and statusstrip.
child forms are created as class and are loaded into the Mdi Form at runtime.
using interface, i was able to execute subs and functions of a child in the Mdi Form and vice versa.
now i need to change property values.. to be exact, i need to change the enabled property of the toolstrip buttons depending on which child form is activated using the form_activated event of the child form.
the problem i now have is how to change the property of the toolstrip item in the Mdi Form.. should i be using interface on this as well by creating subs in the interface and have the Mdi Form implement this interface?
or can i use Property classes for this?
thanks
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Mar 31st, 2009, 07:12 AM
#2
Re: change a property of an item in MdiParent
ChildForm.MdiParent gives you the reference to the parent mdi form. You just cast it to the actual type of your mdi parent and then you can access its members. For exmaple, if I have Form1 is the mdi parent and Form2 is an mdi child, in Form2, I can do:
Code:
Dim myParent As Form1 = DirectCast(Me.MdiParent, Form1)
myParent.Text = "Hello, how are you doing?"
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Mar 31st, 2009, 02:17 PM
#3
Addicted Member
Re: change a property of an item in MdiParent
you can also raise an event on your child form and catch it on the parent, so you can continue execution without worrying about how much the parent has to change before you continue.
-
Mar 31st, 2009, 09:00 PM
#4
Thread Starter
Hyperactive Member
Re: change a property of an item in MdiParent
 Originally Posted by stanav
ChildForm.MdiParent gives you the reference to the parent mdi form. You just cast it to the actual type of your mdi parent and then you can access its members. For exmaple, if I have Form1 is the mdi parent and Form2 is an mdi child, in Form2, I can do:
Code:
Dim myParent As Form1 = DirectCast(Me.MdiParent, Form1)
myParent.Text = "Hello, how are you doing?"
hi,
thanks for the reply..
was just wondering that since this is a plugin architecture, i won' be able to do
Code:
Dim myParent As Form1 = DirectCast(Me.MdiParent, Form1)
since Form1 (Name of MdiParentForm) will not be accessible at design time.
or is this not the case?
 Originally Posted by winsrp
you can also raise an event on your child form and catch it on the parent, so you can continue execution without worrying about how much the parent has to change before you continue.
i will try to dig more about this raise event... first time hearing it 
thanks
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Apr 8th, 2009, 07:06 AM
#5
Thread Starter
Hyperactive Member
Re: change a property of an item in MdiParent
hi all,
i've been trying to study raising events but i just don't get it...
i've been reading this sample here..
http://msdn.microsoft.com/en-us/library/9aackb16.aspx
but i don't see how to apply this to my situation.
can someone explain how this is done?
thanks.
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
-
Apr 8th, 2009, 09:59 AM
#6
Addicted Member
Re: change a property of an item in MdiParent
example
mdi parent code
vb Code:
private sub call_child() Dim Childform As New FRM_MDICHILD AddHandler Childform.NewEvent, AddressOf A_Sub_On_Myself Childform.MdiParent = Me Childform.Show() end sub private sub A_Sub_On_Myself(some_value as integer) label1.text = some_value end sub
mdi child code
vb Code:
Public Event NewEvent(ByVal Info As Integer) private sub extensive_operation for x as integer = 0 to 1000 raiseevent NewEvent(x) next x end sub
so when the child calls the raiseevent, it sends the value of X, out to the world, since this event has a handler on the parent, and it will be caught and sent to the sub that was designated to process that event.. which in this example will change the value of a label.
Hope it helps.
-
Apr 8th, 2009, 05:29 PM
#7
Thread Starter
Hyperactive Member
Re: change a property of an item in MdiParent
thanks... i might be able to come up with something thru this.
VB Version: Microsoft Visual Studio 2008 Professional Edition
.NET Version: Microsoft .NET Framework Version 3.5
OS: Windows XP SP3
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
|