473,418 Members | 2,043 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,418 software developers and data experts.

Reference the calling form.

Is there a way to reference a calling form and pass an object to it?

This is what I'm trying to do:

Form A creates new instance of Form B and then calls it modal.
Form B creates a new instance of PersonalInfo class, makes a call to the db
and fills that class

Here's the tricky part:

I now want to pass the PersonalInfo object to the calling form (Form A) so
it can display this retrieved information.
I was thinking it would be something like: FormB.ParentForm.PersonalInfoObj
= FormA.PersonalInfoObj

but this doesn't seem to work.

Thanks in advance,

Bill
Nov 21 '05 #1
4 1659
Sorry, that should be:

I was thinking it would be something like:
FormB.ParentForm.PersonalInfoObj = FormB.PersonalInfoObj

Nov 21 '05 #2
Hi, William Oliveri
How about doing something like this?

'Inside FormA
With New FormB
.Owner = Me
.ShowDialog()
End With

'Inside FormB
CType(Me.Owner, FormA).Button1.Text = "Hello World"

Hope that helps.

From,
Hon Yuen, Ng
Nov 21 '05 #3
William,

Although I would not do that do I think that what you ask will be possible.

In formA
\\\
dim formB as frmB
frmB.showdialog
dim b as dataset = frmB.a
frmB.Dispose
///
In formB
\\\
Public a as new dataset
///

Your problem will probably be, that the GC has more problems than needed,
because dataset a in frmB will only be garbaged when it is not used anymore
in frmA.

Therefore quickly typed something as
\\\
dim formB as frmB
dim a as new dataset
frmB.a = a
frmB.Dispose
///
And than in frmB
\\\
public a as dataset
///
Has my preference

Just my idea

Cor


Nov 21 '05 #4
"William Oliveri" <wu**@bigvalley.net> schrieb:
Is there a way to reference a calling form and pass an object to it?


What you need in 'Form2' is a reference to your instance of 'Form1'. You
can pass the reference to 'Form1' in a property when showing 'Form2' from
'Form1':

Code for 'Form1':

\\\
Dim f As New Form2()
f.Form1 = Me
f.Show()
///

Code for 'Form2':

\\\
Private m_Form1 As Form1

Public Property Form1() As Form1
Get
Return m_Form1
End Get
Set(ByVal Value As Form1)
m_Form1 = Value
End Set
End Property
///

You can access 'Form1''s properties inside 'Form2' with 'Me.Form1', for
example, 'Me.Form1.Button1.Text = "Bla"'.

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainform&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5

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

Similar topics

12
by: Bill Todd | last post by:
Form B needs to call a public method of Form A. How can form B get a reference to the instance of Form A using its name or any other method? Is there a collection of form instances that can be...
3
by: Giovanni Bassi | last post by:
Hello all, I have prepared a simple procedure to open forms only once. Here it is: -//- Private Sub OpenChildForm(ByRef objFormToOpen As System.Windows.Forms.Form, ByVal TypeToCreate As...
3
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
0
by: guy | last post by:
I have an application that references another assembly and calls methods in it - fine so far however one of the methods i call takes a Form from of the calling assembly as a parameter(actually...
1
by: Mike H | last post by:
I can't seem to figure out the right thing to search on, so I thought I'd just provide an example and see if someone can point me to some tips. What I have is an Automation Server that has a...
9
by: Jack | last post by:
If I don't specify "ref" in the argument list when passing an array to the callee, I am passing the array (reference) by value. But this makes me confused because it actually means a "reference" of...
11
by: thatguyNYC | last post by:
This is a complicated one... I have a modal form that lets the user preview some text, then either click Submit or Close. This form is called from several other forms. What I would like, since...
9
by: Brad Pears | last post by:
I have the following code that references a "textbox" on a form. I want to pass the value of this textbox to a stored procedure as a parameter. This code is located on a different form obviously. I...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.