473,490 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Multiple child forms - updating the right one

I've got an mdiParent form. I open an instance of a child form like
this:

Dim frmChild as New frmCustomers
frmChild.Show()

I've got a few of these open at a time. On each frmChild I open
another form that displays customer data. When I make changes and save
the customer data, I need the updated data to show on the correct
frmChild. How do I know which form opened the customer data form and
how would I reference it?
Sep 27 '06 #1
6 1704
You could use a controlling class that opens all the child forms,
specifying the mdi form as its mdiform. The controlling class can keep
track of which form has the request to open the data form, and the
controlling class can manage that also. So when the update needs to be
done, the controlling class then handles the placement of the data into
the correct form.

Tom

Kevin wrote:
>I've got an mdiParent form. I open an instance of a child form like
this:

Dim frmChild as New frmCustomers
frmChild.Show()

I've got a few of these open at a time. On each frmChild I open
another form that displays customer data. When I make changes and save
the customer data, I need the updated data to show on the correct
frmChild. How do I know which form opened the customer data form and
how would I reference it?

Sep 27 '06 #2
Could you give me a "for instance"?
On Wed, 27 Sep 2006 17:30:20 -0400, tomb <to**@technetcenter.com>
wrote:
>You could use a controlling class that opens all the child forms,
specifying the mdi form as its mdiform. The controlling class can keep
track of which form has the request to open the data form, and the
controlling class can manage that also. So when the update needs to be
done, the controlling class then handles the placement of the data into
the correct form.

Tom

Kevin wrote:
>>I've got an mdiParent form. I open an instance of a child form like
this:

Dim frmChild as New frmCustomers
frmChild.Show()

I've got a few of these open at a time. On each frmChild I open
another form that displays customer data. When I make changes and save
the customer data, I need the updated data to show on the correct
frmChild. How do I know which form opened the customer data form and
how would I reference it?

Sep 27 '06 #3
Hello Kevin,

-CALLER-
tFormVariable.Show(me)

-DATA FORM-
if not nothing is me.owner then
' We got a live one.
endif

-Boo

I've got an mdiParent form. I open an instance of a child form like
this:

Dim frmChild as New frmCustomers
frmChild.Show()
I've got a few of these open at a time. On each frmChild I open
another form that displays customer data. When I make changes and save
the customer data, I need the updated data to show on the correct
frmChild. How do I know which form opened the customer data form and
how would I reference it?

Sep 28 '06 #4
Thanks, but the .Show(Me) function won't work with MDI Child forms,
which my form needs to be.
On Thu, 28 Sep 2006 00:43:22 +0000 (UTC), GhostInAK
<gh*******@gmail.comwrote:
>Hello Kevin,

-CALLER-
tFormVariable.Show(me)

-DATA FORM-
if not nothing is me.owner then
' We got a live one.
endif

-Boo

>I've got an mdiParent form. I open an instance of a child form like
this:

Dim frmChild as New frmCustomers
frmChild.Show()
I've got a few of these open at a time. On each frmChild I open
another form that displays customer data. When I make changes and save
the customer data, I need the updated data to show on the correct
frmChild. How do I know which form opened the customer data form and
how would I reference it?
Sep 28 '06 #5
Hi Kevin,
You would add code that works in the same way the MDIParent calls
the ChildForm.

eg.
Dim frmChild as New frmCustomers
frmChild.MdiParent = Me
frmChild.Show()
>From the code above you now have an MDIParent with a linked Child as
you orginally stated.
Then you state you call another form from the child to amend customer
data.

eg.
Dim frmNewForm as new frmCustomerData
frmNewForm.Show()

**** THE FIX ****
In the customer data form you load from the child, you need to add a
'/ ADD TO CUSTOMER DATA FORM
Private _ParentForm As Form
Public Property ParentForm() As Form
Get
Return _ParentForm
End Get
Set(ByVal value As Form)
_ParentForm = value
End Set
End Property

Then you call the customer data form as below
Dim frmNewForm as new frmCustomerData
frmNewForm.ParentForm = frmChild
frmNewForm.Show()

This allows you from the customer data form to alter the field values
on the child form
_ParentForm.TextBox1.Text = "Joe Bloggs"

Regards,
Tony
Kevin wrote:
I've got an mdiParent form. I open an instance of a child form like
this:

Dim frmChild as New frmCustomers
frmChild.Show()

I've got a few of these open at a time. On each frmChild I open
another form that displays customer data. When I make changes and save
the customer data, I need the updated data to show on the correct
frmChild. How do I know which form opened the customer data form and
how would I reference it?
Sep 28 '06 #6
When I've tried these suggestions, other forms weren't able to access
my 'CustomerData' form. So here's what I came up with in case anybody
cares or wants to do the same thing:

'Find the correct frmCustomers that opened this form and update the
grid
For X = 0 To (frmMain.MdiChildren.Length) - 1
Dim tempChild As Form = CType(frmMain.MdiChildren(X),
Form)
If tempChild.Name = "frmCustomers" Then
Dim CallingForm As frmCustomers =
DirectCast(tempChild, frmCustomers)
If CallingForm.txtCourseID.Text = Me.txtCourseID.Text
Then
CallingForm.LoadChkbox()

'Locate the updated record in the Grid1
For Y = 0 To CallingForm.Grid1.Rows.Count - 1
If CallingForm.Grid1.Rows(Y).Cells(0).Value =
txtCustomerNumber.Text Then
CallingForm.Grid1.CurrentCell =
CallingForm.Grid1.Rows(Y).Cells(1)
Exit For
End If
Next Y
Me.Close()
CallingForm.Show()
CallingForm.Grid1.Focus()
Exit For
End If
End If
Next X

When I open the CustomerData form, I fill a textbox with the customer
number on both forms. I then look for that customer number in the
textbox on all frmCustomers. It works.

On 28 Sep 2006 15:05:58 -0700, "Sca_Tone" <sw**********@hotmail.com>
wrote:
>Hi Kevin,
You would add code that works in the same way the MDIParent calls
the ChildForm.

eg.
Dim frmChild as New frmCustomers
frmChild.MdiParent = Me
frmChild.Show()
>>From the code above you now have an MDIParent with a linked Child as
you orginally stated.
Then you state you call another form from the child to amend customer
data.

eg.
Dim frmNewForm as new frmCustomerData
frmNewForm.Show()

**** THE FIX ****
In the customer data form you load from the child, you need to add a
'/ ADD TO CUSTOMER DATA FORM
Private _ParentForm As Form
Public Property ParentForm() As Form
Get
Return _ParentForm
End Get
Set(ByVal value As Form)
_ParentForm = value
End Set
End Property

Then you call the customer data form as below
Dim frmNewForm as new frmCustomerData
frmNewForm.ParentForm = frmChild
frmNewForm.Show()

This allows you from the customer data form to alter the field values
on the child form
_ParentForm.TextBox1.Text = "Joe Bloggs"

Regards,
Tony
Kevin wrote:
>I've got an mdiParent form. I open an instance of a child form like
this:

Dim frmChild as New frmCustomers
frmChild.Show()

I've got a few of these open at a time. On each frmChild I open
another form that displays customer data. When I make changes and save
the customer data, I need the updated data to show on the correct
frmChild. How do I know which form opened the customer data form and
how would I reference it?
Oct 2 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1593
by: tdmailbox | last post by:
I have added search buttons to some access fomms. I have a seach button in both the parent and the child form. My issue is that when I search for a last name in the last_name field of the...
8
4913
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
3
4016
by: Roland Wolters | last post by:
Hi, I have parent-form that displays a list of product-details. When the user clicks on a line a child form opens that displays further details. The user then can alter these details. On the...
3
3193
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI...
10
3980
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
7
3082
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form...
7
2722
by: Jeff | last post by:
I plan to write a Windows Forms MDI application for a medical office. Users must be able to select a patient and view related information on multiple forms; with1-4 forms opened at the same time...
2
4887
by: Mario | last post by:
Hi, I am trying to create an application with multiple windows forms. The problem that I have is that after creating the window forms, I do not know how to open formN after closing Main form. ...
0
2028
by: emalcolm_FLA | last post by:
Hello and TIA for any help with this non profit Christmas assistance project. I have an applicant (app history) and child (child history) tables (4 total). I need to grab the next available (in...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7146
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
7183
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
7356
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...
0
5448
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,...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
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 ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.