By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

MDI parent to child communication problems

P: n/a
I am really trying to find the best OOP way of doing this. I have a
parent MDI form with multiple children and I am trying to communicate
variables between them. I have been able to successfully get the
parent form to read the child variable by using a Public Property in
one of my child forms like such:

Public ReadOnly Property ID() As String
Get
Return strID
End Get
End Property

When this value is updated I am having the child use the RaiseEvent to
get the parent form to then read this Property from the Child window:

strID = lstExistingID.SelectedItems(0).Text
RaiseEvent IDSelected()
Private Sub ChildFRM_IDSelected() Handles frmChild.IDSelected
strID = frmChild.ID
End Sub
The problem I am running into is now retrieving this variable from my
parent to a different child. It seems that I have to declare or
somehow define the form for the MDI Parent in order to access its
properties/functions. I can successfully create a reference in the
other child form using:

Dim frmMainMDIParent As fclsMainMDIParent

but as soon as I uncomment my Property get statement:

lstTransactionLog.Items.Add("Ready to process ID " &
frmMainMDIParent.ID)

I start getting an exception: An unhandled exception of type
'System.OutOfMemoryException' occurred in system.windows.forms.dll

Additional information: Error creating window handle.
From Main MDI Parent Form:
If e.Button Is tbbTransactionControl Then
frmTransactionControl.MdiParent = Me
If Not frmTransactionControl.Visible Then
stops here----> frmTransactionControl.Show()
End If
End If

I hope this provides enough information for someone to give me a
solution. I am also interested in any suggested reference sites/books
to show me the best way to handle inter-MDI communication. TIA!
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Have you tried using the Parent Property on the Child forms?

"Jim Shank" <go**************@spamgourmet.com> wrote in message
news:93**************************@posting.google.c om...
I am really trying to find the best OOP way of doing this. I have a
parent MDI form with multiple children and I am trying to communicate
variables between them. I have been able to successfully get the
parent form to read the child variable by using a Public Property in
one of my child forms like such:

Public ReadOnly Property ID() As String
Get
Return strID
End Get
End Property

When this value is updated I am having the child use the RaiseEvent to
get the parent form to then read this Property from the Child window:

strID = lstExistingID.SelectedItems(0).Text
RaiseEvent IDSelected()
Private Sub ChildFRM_IDSelected() Handles frmChild.IDSelected
strID = frmChild.ID
End Sub
The problem I am running into is now retrieving this variable from my
parent to a different child. It seems that I have to declare or
somehow define the form for the MDI Parent in order to access its
properties/functions. I can successfully create a reference in the
other child form using:

Dim frmMainMDIParent As fclsMainMDIParent

but as soon as I uncomment my Property get statement:

lstTransactionLog.Items.Add("Ready to process ID " &
frmMainMDIParent.ID)

I start getting an exception: An unhandled exception of type
'System.OutOfMemoryException' occurred in system.windows.forms.dll

Additional information: Error creating window handle.
From Main MDI Parent Form:
If e.Button Is tbbTransactionControl Then
frmTransactionControl.MdiParent = Me
If Not frmTransactionControl.Visible Then
stops here----> frmTransactionControl.Show()
End If
End If

I hope this provides enough information for someone to give me a
solution. I am also interested in any suggested reference sites/books
to show me the best way to handle inter-MDI communication. TIA!

Nov 20 '05 #2

P: n/a
I assume you mean by using the directcast method such as:

strLocalID = DirectCast(Me.MdiParent, fclsParentForm).ID

to access the parent properties. This does in fact work but is it the
best OOP way to do it? I am toying today with using a separate module
to declare all of my classes and functions to instantiate the classes
so I can reference them outside the forms without redeclaring the
forms. When I redeclare the parent form in the child form is when I
get into the most trouble because it ends up in an endless loop (child
declares the parent which redeclares the child and so on until you get
an OutOfMemory exception). Thanks for your feedback and let me know
what else you think.
Jim
"Mike Bulava" <mb*****@comcast.net> wrote in message news:<uL**************@TK2MSFTNGP10.phx.gbl>...
Have you tried using the Parent Property on the Child forms?

"Jim Shank" <go**************@spamgourmet.com> wrote in message
news:93**************************@posting.google.c om...
I am really trying to find the best OOP way of doing this. I have a
parent MDI form with multiple children and I am trying to communicate
variables between them. I have been able to successfully get the
parent form to read the child variable by using a Public Property in
one of my child forms like such:

Public ReadOnly Property ID() As String
Get
Return strID
End Get
End Property

When this value is updated I am having the child use the RaiseEvent to
get the parent form to then read this Property from the Child window:

strID = lstExistingID.SelectedItems(0).Text
RaiseEvent IDSelected()
Private Sub ChildFRM_IDSelected() Handles frmChild.IDSelected
strID = frmChild.ID
End Sub
The problem I am running into is now retrieving this variable from my
parent to a different child. It seems that I have to declare or
somehow define the form for the MDI Parent in order to access its
properties/functions. I can successfully create a reference in the
other child form using:

Dim frmMainMDIParent As fclsMainMDIParent

but as soon as I uncomment my Property get statement:

lstTransactionLog.Items.Add("Ready to process ID " &
frmMainMDIParent.ID)

I start getting an exception: An unhandled exception of type
'System.OutOfMemoryException' occurred in system.windows.forms.dll

Additional information: Error creating window handle.
From Main MDI Parent Form:
If e.Button Is tbbTransactionControl Then
frmTransactionControl.MdiParent = Me
If Not frmTransactionControl.Visible Then
stops here----> frmTransactionControl.Show()
End If
End If

I hope this provides enough information for someone to give me a
solution. I am also interested in any suggested reference sites/books
to show me the best way to handle inter-MDI communication. TIA!

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.