473,695 Members | 2,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.S electedItems(0) .Text
RaiseEvent IDSelected()
Private Sub ChildFRM_IDSele cted() Handles frmChild.IDSele cted
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 frmMainMDIParen t As fclsMainMDIPare nt

but as soon as I uncomment my Property get statement:

lstTransactionL og.Items.Add("R eady to process ID " &
frmMainMDIParen t.ID)

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

Additional information: Error creating window handle.
From Main MDI Parent Form:
If e.Button Is tbbTransactionC ontrol Then
frmTransactionC ontrol.MdiParen t = Me
If Not frmTransactionC ontrol.Visible Then
stops here----> frmTransactionC ontrol.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 3432
Have you tried using the Parent Property on the Child forms?

"Jim Shank" <go************ **@spamgourmet. com> wrote in message
news:93******** *************** ***@posting.goo gle.com...
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.S electedItems(0) .Text
RaiseEvent IDSelected()
Private Sub ChildFRM_IDSele cted() Handles frmChild.IDSele cted
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 frmMainMDIParen t As fclsMainMDIPare nt

but as soon as I uncomment my Property get statement:

lstTransactionL og.Items.Add("R eady to process ID " &
frmMainMDIParen t.ID)

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

Additional information: Error creating window handle.
From Main MDI Parent Form:
If e.Button Is tbbTransactionC ontrol Then
frmTransactionC ontrol.MdiParen t = Me
If Not frmTransactionC ontrol.Visible Then
stops here----> frmTransactionC ontrol.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.M diParent, 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*****@comcas t.net> wrote in message news:<uL******* *******@TK2MSFT NGP10.phx.gbl>. ..
Have you tried using the Parent Property on the Child forms?

"Jim Shank" <go************ **@spamgourmet. com> wrote in message
news:93******** *************** ***@posting.goo gle.com...
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.S electedItems(0) .Text
RaiseEvent IDSelected()
Private Sub ChildFRM_IDSele cted() Handles frmChild.IDSele cted
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 frmMainMDIParen t As fclsMainMDIPare nt

but as soon as I uncomment my Property get statement:

lstTransactionL og.Items.Add("R eady to process ID " &
frmMainMDIParen t.ID)

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

Additional information: Error creating window handle.
From Main MDI Parent Form:
If e.Button Is tbbTransactionC ontrol Then
frmTransactionC ontrol.MdiParen t = Me
If Not frmTransactionC ontrol.Visible Then
stops here----> frmTransactionC ontrol.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
27594
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' pointer? Thx Paul
16
2668
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 option. Let's call the id of a class "cid" (for "class id"). The function signature should look like this: ******************************************
3
9698
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 parent menu functions. if i select draw line in MDI parent, the line should be drawn in current active child..any URLS for this or guide me to achieve this communication... -- Mähésh Kumär. R
2
23501
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 window to open a child window thru javascript window.open 2) I have some functionality in the child window that changes the data
6
9419
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 open/closed and their current state. now i can't. before i didn't have to declare numerous named instances each time i loaded or unloaded a form.
10
19610
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 Class Parent '*** HOW TO DECLARE IT *** Dim Age As String = "1/1/2000"
2
2748
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 break that connection from the parent side or the child side, it doesn't matter as long as the communication link is completely broken. I don't want the parent to be aware of the child and vice-versa.
1
1565
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. Then if max is reached and one more is asked to run by the user from the command line, the parent must wait and see if there is a free spot. (in the array of children) Now i know i have to use waitpid somewhere, but using it as: wait child1,...
0
1349
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 parent class using Events/Delegates. What would be a nicest way to child to communicate to parent using Events or Delegates? Sample would be nice,
0
8553
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9112
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8971
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8815
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6482
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4332
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.