473,394 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

MDI parent to child communication problems

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
2 3384
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
Hi all, Here is what I am trying to do. I have a parent class calling a child class. when one function in child class is called, i need to call parent class' function. How can I get parent class'...
16
by: Suzanne Vogel | last post by:
Hi, I've been trying to write a function to test whether one class is derived from another class. I am given only id's of the two classes. Therefore, direct use of template methods is not an...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
2
by: Raj | last post by:
Hi All, I have a problem with trying to refresh the parent window from child window in order to update data in the parent window. The sequence of events are 1) I click a button in the parent...
6
by: Edwinah63 | last post by:
Hi everyone, could someone give me some thoughts on the best way to manage mdi parent and child forms? in vb6 i could scroll through the forms collection and determine which forms were...
10
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public...
2
by: epaetz | last post by:
Is there a way to decouple the linkage between a parent and a child window? Does the parent window have any sort of a collection that holds all the children that it has spawned? I want to...
1
by: Sebouh | last post by:
Hello guys. This time, i need to implement waitpid in order to know if one of the children of a parent has finished executing. The assignment requires me to run a limited number of child processes....
0
by: uupi_duu | last post by:
Hello, I have a parent class which creates and uses child class. Child class use it's own methods for different tasks. If an error occurs in child classes methods I would like to inform it to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.