473,714 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do I pass a parameter or argument from one windows form to another?

I have an application which uses mutliple forms for different tasks,
all of which are mdi child forms to the applications MDI Parent form.

One of these child forms (form1) will be used to select a record from
somewhere within a hierarchy (using a treeview and listbox to narrow
down the search) and then the details from this record should be
displayed on an entirely different child form (form2) by the click of
a button.

What I want to know is how do I get this click of the button to open a
new form, passing over the ID value of the record selected?

I'm sure it has something to do with constructors, but as I've never
done it, I don't know how.

Any sample code for the form2's constructor, and how to open and pass
this value to form2 will be greatly appreciated.

Mar 7 '07 #1
2 2327
On Mar 7, 6:35 am, "Karl Rhodes" <googlegro...@t lbsolutions.com >
wrote:
I have an application which uses mutliple forms for different tasks,
all of which are mdi child forms to the applications MDI Parent form.

One of these child forms (form1) will be used to select a record from
somewhere within a hierarchy (using a treeview and listbox to narrow
down the search) and then the details from this record should be
displayed on an entirely different child form (form2) by the click of
a button.

What I want to know is how do I get this click of the button to open a
new form, passing over the ID value of the record selected?

I'm sure it has something to do with constructors, but as I've never
done it, I don't know how.

Any sample code for the form2's constructor, and how to open and pass
this value to form2 will be greatly appreciated.
You don't need to muck with the new form's constructor. Just create a
property in the new form and after you instantiate the new form and
before you show it, set the value of the property to the value you
want to pass to the new form. Then after the new form is shown it can
access the value from it's own local property.

Mar 7 '07 #2
On 7 Mar, 13:09, z...@constructi on-imaging.com wrote:
On Mar 7, 6:35 am, "Karl Rhodes" <googlegro...@t lbsolutions.com >
wrote:
I have an application which uses mutliple forms for different tasks,
all of which are mdi child forms to the applications MDI Parent form.
One of these child forms (form1) will be used to select a record from
somewhere within a hierarchy (using a treeview and listbox to narrow
down the search) and then the details from this record should be
displayed on an entirely different child form (form2) by the click of
a button.
What I want to know is how do I get this click of the button to open a
new form, passing over the ID value of the record selected?
I'm sure it has something to do with constructors, but as I've never
done it, I don't know how.
Any sample code for the form2's constructor, and how to open and pass
this value to form2 will be greatly appreciated.

You don't need to muck with the new form's constructor. Just create a
property in the new form and after you instantiate the new form and
before you show it, set the value of the property to the value you
want to pass to the new form. Then after the new form is shown it can
access the value from it's own local property.
Perfect... Just what I was after.

Thanks.

Mar 7 '07 #3

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

Similar topics

46
3510
by: J.R. | last post by:
Hi folks, The python can only support passing value in function call (right?), I'm wondering how to effectively pass a large parameter, such as a large list or dictionary? It could achieved by pointer in C++, is there such way in Python? Thansk in advance. J.R.
110
9930
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object must be an object instead of
3
3886
by: Lyn | last post by:
Hi, I have been experiencing a problem passing a LIKE statement in the WHERE argument of a DoCmd.Openform statement. I have posted that issue separately. However, in an attempt to work around the problem, I thought of using OPENARGS to pass information to the form being opened (instead of using WHERE). In the parent form, I have generated a RecordSet (RS) with the information
3
2932
by: Mikey | last post by:
I'm really new at the c# scene and I think I've proabably jumped in the deep end :) I'm really interested in developing Windows Applications but most sources seem to deal with web development and c#. So can anyone help me with the following: This one relates to a project I've started. How can I make the contents of textboxes in form1 available to form2
9
12873
by: Jay Douglas | last post by:
Hello, I am needing to pass a class object (this) by reference to a method in a different class. When I do the following code I get the error (Cannot pass '<this>' as a ref or out argument because it is read-only) .. Is there any way to make <this> not read-only? I have simplified the following code. There is a Task class and a Data Class. I am trying to pass the task class by ref to the data class. public class Task {
0
1557
by: Budi | last post by:
Hi, We try callback C# method from C++ DLL using delegate, using delegate without argument works fine for me however the CallBackFunctionWithParameter which call delegate with parameter crash the application after being called . Any suggestion will help and really appreaciated Thanks
1
2813
by: eBob.com | last post by:
I have some code which is trying to determine where text will wrap in a custom text box (which Inherits from Control). It determines the number of characters which will fit in the first line, but then encounters an exception when it calls MeasureCharacterRanges to see if the next character, i.e. the one destined to become the first character of the second line, will fit. The message says only "Invalid parameter" - it does not say which...
24
55208
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new EventHandler(Onbutton_click); I want to pass more information related that event. & want to use that
12
11097
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
0
8801
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
9174
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...
1
9074
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
7953
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...
0
5947
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4464
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
4725
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3158
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
2520
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.