473,657 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting reference to parent form

Hi

I have posted this question several times but have received no reply. I have
a main form which contains a panel which in turn contains a child form, like
this; MainForm->MyPanel->ChildForm. The question is; how can I, from the
child form, get a reference to the main form? If I try to do dim frm as new
mainform then I get reference to a second instance of the mainform which is
not the same as the original instance of the mainform.

Isn't there a way to from child form do; childform.paren t.parent or
something similar? Anyone has any ideas?

Thanks

Regards

Nov 20 '05 #1
16 1647
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
I have posted this question several times but have received no reply. I have
a main form which contains a panel which in turn contains a child form, like
this; MainForm->MyPanel->ChildForm. The question is; how can I, from the
child form, get a reference to the main form? If I try to do dim frm as new
mainform then I get reference to a second instance of the mainform which is
not the same as the original instance of the mainform.


Have a look at the control's 'FindForm' method.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Has this been tested by anyone?

Regards

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:uY******** ******@TK2MSFTN GP11.phx.gbl...
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
I have posted this question several times but have received no reply. I have a main form which contains a panel which in turn contains a child form, like this; MainForm->MyPanel->ChildForm. The question is; how can I, from the
child form, get a reference to the main form? If I try to do dim frm as new mainform then I get reference to a second instance of the mainform which is not the same as the original instance of the mainform.


Have a look at the control's 'FindForm' method.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
Has this been tested by anyone?


What's the problem with it?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
You may not be getting a reply becuase you are cross posting ...

James
"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:Oe******** ******@TK2MSFTN GP11.phx.gbl...
Hi

I have posted this question several times but have received no reply. I have a main form which contains a panel which in turn contains a child form, like this; MainForm->MyPanel->ChildForm. The question is; how can I, from the
child form, get a reference to the main form? If I try to do dim frm as new mainform then I get reference to a second instance of the mainform which is not the same as the original instance of the mainform.

Isn't there a way to from child form do; childform.paren t.parent or
something similar? Anyone has any ideas?

Thanks

Regards

Nov 20 '05 #5
Yes, it has and it works fine. What is the problem?

--
B\rgds
100

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:et******** ******@TK2MSFTN GP11.phx.gbl...
Has this been tested by anyone?

Regards

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:uY******** ******@TK2MSFTN GP11.phx.gbl...
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
I have posted this question several times but have received no reply. I
have
a main form which contains a panel which in turn contains a child
form,
like this; MainForm->MyPanel->ChildForm. The question is; how can I, from
the child form, get a reference to the main form? If I try to do dim frm
as new mainform then I get reference to a second instance of the mainform
which
is not the same as the original instance of the mainform.


Have a look at the control's 'FindForm' method.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


Nov 20 '05 #6
Check the forms Parent property, or if its an MDI application, MdiParent.
They return the control thats containing this one.

/Dan

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:Oe******** ******@TK2MSFTN GP11.phx.gbl...
Hi

I have posted this question several times but have received no reply. I have a main form which contains a panel which in turn contains a child form, like this; MainForm->MyPanel->ChildForm. The question is; how can I, from the
child form, get a reference to the main form? If I try to do dim frm as new mainform then I get reference to a second instance of the mainform which is not the same as the original instance of the mainform.

Isn't there a way to from child form do; childform.paren t.parent or
something similar? Anyone has any ideas?

Thanks

Regards

Nov 20 '05 #7
All in the right forums. :)

"James Westgate [Crainiate]" <ja***@nospam.c rainiate.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
You may not be getting a reply becuase you are cross posting ...

James
"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:Oe******** ******@TK2MSFTN GP11.phx.gbl...
Hi

I have posted this question several times but have received no reply. I

have
a main form which contains a panel which in turn contains a child form,

like
this; MainForm->MyPanel->ChildForm. The question is; how can I, from the
child form, get a reference to the main form? If I try to do dim frm as

new
mainform then I get reference to a second instance of the mainform which

is
not the same as the original instance of the mainform.

Isn't there a way to from child form do; childform.paren t.parent or
something similar? Anyone has any ideas?

Thanks

Regards


Nov 20 '05 #8
If it passes Herfried, it must be OK. :)

Regards

"James Westgate [Crainiate]" <ja***@nospam.c rainiate.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
You may not be getting a reply becuase you are cross posting ...

James
"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:Oe******** ******@TK2MSFTN GP11.phx.gbl...
Hi

I have posted this question several times but have received no reply. I

have
a main form which contains a panel which in turn contains a child form,

like
this; MainForm->MyPanel->ChildForm. The question is; how can I, from the
child form, get a reference to the main form? If I try to do dim frm as

new
mainform then I get reference to a second instance of the mainform which

is
not the same as the original instance of the mainform.

Isn't there a way to from child form do; childform.paren t.parent or
something similar? Anyone has any ideas?

Thanks

Regards


Nov 20 '05 #9
I have used this on my child form;

Dim myForm As Form = Me.FindForm()

Using watch I can see that Me is MyProject.Child Form but the value of myForm
is also MyProject.Child Form!! I would have thought that it would be
MyProject.MainF orm.

Regards

From Watch Window;

Name, Value, Type
+ myForm, {MyProject.Chil dForm}, System.Windows. Forms.Form
+ Me, {MyProject.Chil dForm }, Contacts.frmCli ents

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ed******** ******@TK2MSFTN GP10.phx.gbl...
* "John" <jo**@nospam.in fovis.co.uk> scripsit:
Has this been tested by anyone?


What's the problem with it?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #10

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

Similar topics

7
2050
by: vindaloo1 | last post by:
I'm using Access 2000 and I have a main form and a subform. When a control on the subform is updated I am trying to update a control on the mainform. But instead of updating the control on the main form's current record, it updates the main form's control on every record. This is the code I'm using for this: Set cnn = CurrentProject.Connection strSQL = "SELECT SUM(AmountPaid)AS SumAmountPaid FROM BillPayments WHERE " & _
5
2250
by: Thelma Lubkin | last post by:
I have a form/subform with the common one-to-many relationship. The form allows user to display records and move to other records via the selector, to add,delete, and edit them, with the related records displayed in the subform going along for the ride. The parent form's recordset has fields string integer COLORNAME CLASSSIZE and a few more that aren't relevant here.
0
1018
by: Ghafran Abbas | last post by:
Use this function to get the name of the form in asp.net. This can be used if the name of the form on the client is needed, for example, you might need the form name in javascript. Modify the return to statement to return what is needed. For the "ctrl" parameter, pass the page reference or any control reference located inside the form. ==================Begin Code=============== Public Function GetFormName(ByVal ctrl As Control) As...
4
2807
by: eBob.com | last post by:
I have a "parent" form (if that's the right terminology), Form1. I declare two public values in the parent form : Public Class Form1 Inherits System.Windows.Forms.Form Public CurDir As String = Directory.GetCurrentDirectory() 'used by FormGetJobOutput Public PubUser As String 'tbxUser.text value for subForms In the "child" form, I call it FormGetJobOutput, I reference these two public values ...
3
1397
by: Llorenc Sole | last post by:
Hello, Is it possible to get a reference to a form's document object exclusively from a reference to the same form? I mean, for example, if I have: var f1 = document.forms; var f2 = parent.document.forms; var f3 = top.document.forms;
4
2233
by: Ravi Kishore | last post by:
Hi all, I have a problem while sending the data to and fro a JSP page. When i click a link on a JSP page(say parent.jsp), i have to open a diff page(say child.jsp), get the data from that page and pass that data to the parent.jsp and do some actions with the data i recently got. I am not using window.open(...)..so i definitely can't use opener object. Also i can't use form.action(parent.jsp?...) as i have to do database hits to open the...
14
3308
by: (PeteCresswell) | last post by:
I've got a form (frmDeal) that has a subform (frmDeal_Tranche) that has a subform (frmDeal_TrancheCusip). When I try to refer to properties on the "Cusip" form at the end of the chain, MS Access is throwing "2455: Expression has invalid reference to Property Form/Report" In an Immediate window: ------------------------------------------
2
1864
by: Thorgal | last post by:
Hello all I have 2 questions First: I'm trying to print a Listview from an mdichild but how can i address this listview. For example, FrmMain is my Main form. In this Main form I have several mdichildren.
0
8385
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
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,...
1
8502
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8602
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...
1
6162
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
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.