473,587 Members | 2,527 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pass a variable from one form to another

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
in a Windows Application?

Can anyone give me the address of some good sites dealing
with c# and Windows Apps

thanks in advance........ .
Nov 15 '05 #1
3 2928
Mikey,

You probably want to start off with http://www.windowsforms.com. This
is a good start. You might also want to check out http://www.gotdotnet.com.

To do what you want to do, you will first have to set the accessor for
all of the controls in your project (or at least the ones that you want to
access) to public. Once you have that, then you can pass the instance of
your form with the controls you want to access to the second form, either
through a property, or through a parameter on a method. A form is like any
other object that you pass around and set values on.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mikey" <an*******@disc ussions.microso ft.com> wrote in message
news:08******** *************** *****@phx.gbl.. .
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
in a Windows Application?

Can anyone give me the address of some good sites dealing
with c# and Windows Apps

thanks in advance........ .

Nov 15 '05 #2
Nicholas,

Thanks for the sites - I've been browsing them most of the
day and picked up bits and pieces - thanks again.

I must say I'm a bit dumb though - no matter what I tinker
with I can't get form2 to 'see' any of the data from form1.

For example, I have a text box named txtDrv and I want to
be able to pass txtDrv.Text as a string in form1 and
form2 - form1 is fine, but as I say, I can't get form2 to
see it.

I'm sure it's not that hard but I'm being dumber than
usual I think :) so any help would be great, even if
someone can spare the time to give me an example of what
to type and where to put it in the code.

Sorry for the hassle....
-----Original Message-----
Mikey,

You probably want to start off with http://www.windowsforms.com. Thisis a good start. You might also want to check out http://www.gotdotnet.com.
To do what you want to do, you will first have to set the accessor forall of the controls in your project (or at least the ones that you want toaccess) to public. Once you have that, then you can pass the instance ofyour form with the controls you want to access to the second form, eitherthrough a property, or through a parameter on a method. A form is like anyother object that you pass around and set values on.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mikey" <an*******@disc ussions.microso ft.com> wrote in messagenews:08******* *************** ******@phx.gbl. ..
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 in a Windows Application?

Can anyone give me the address of some good sites dealing with c# and Windows Apps

thanks in advance........ .

.

Nov 15 '05 #3
http://www.syncfusion.com/FAQ/WinFor...c95c.asp#q952q

--
William Stacey, MVP

"Mikey" <an*******@disc ussions.microso ft.com> wrote in message
news:07******** *************** *****@phx.gbl.. .
Nicholas,

Thanks for the sites - I've been browsing them most of the
day and picked up bits and pieces - thanks again.

I must say I'm a bit dumb though - no matter what I tinker
with I can't get form2 to 'see' any of the data from form1.

For example, I have a text box named txtDrv and I want to
be able to pass txtDrv.Text as a string in form1 and
form2 - form1 is fine, but as I say, I can't get form2 to
see it.

I'm sure it's not that hard but I'm being dumber than
usual I think :) so any help would be great, even if
someone can spare the time to give me an example of what
to type and where to put it in the code.

Sorry for the hassle....
-----Original Message-----
Mikey,

You probably want to start off with

http://www.windowsforms.com. This
is a good start. You might also want to check out

http://www.gotdotnet.com.

To do what you want to do, you will first have to set

the accessor for
all of the controls in your project (or at least the ones

that you want to
access) to public. Once you have that, then you can pass

the instance of
your form with the controls you want to access to the

second form, either
through a property, or through a parameter on a method.

A form is like any
other object that you pass around and set values on.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mikey" <an*******@disc ussions.microso ft.com> wrote in

message
news:08******* *************** ******@phx.gbl. ..
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 in a Windows Application?

Can anyone give me the address of some good sites dealing with c# and Windows Apps

thanks in advance........ .

.

Nov 15 '05 #4

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

Similar topics

2
2357
by: HelLind | last post by:
Hello everyone ! Is there any way to pass session variables between two websites ( diff domains) ? I've two websites and I want to integrate them. I used to use the querystring but there is a limit to length of the querystring. I've tried ASP-TEAR but I doubt it can work.
11
8793
by: Vanessa | last post by:
Hi, I would like to know whether there's any way for me to pass an object by reference to another form? Regards Vanessa
1
4105
by: carmen | last post by:
I am using the code below to open another page depending on what is selected. This is working ok but I would like to streamline it so that I will hot have to create a page everytime a new category code is added. How can I pass the category code to another page as a variable after it is selected? That way I would only need one page that can be...
3
3879
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...
3
2209
by: Martin | last post by:
I have a calendar form that sends the inputted date back to a text box . Using the GET method, I would like to pass the date as a variable to another asp page. How do I do this? Thanks.
1
7736
by: drec | last post by:
I need to pass a variable from script1.php to script2.php. The problem is that these scripts use frames and therefore I am able to pass the variable through the URL. It also does not use forms to set this variable, so i cannot pass it this way either. So to simplify I have : script1.php <?php $var1 = value;
17
7063
by: Rabbit | last post by:
Hi, On my 1st page, i have a function which gets a new ID value and need to transfer to another immediately. which I want to get in 2nd page using Request.form("txtID"), but doesn't work, the returned value is "" Anybody know how to set this value on 1st page properly, in order to let 2nd page catch it? I don't want to use querystring...
14
3599
by: =?Utf-8?B?Umljaw==?= | last post by:
I have seen examples of passing data from FormB to FormA (Parent To Child) but I need an example of passind data from FormA to FormB. My main form is FormA; I will enter some data in textboxes and click a button to bring up FormB which needs to display values entered in FormA. Thanks in advance.
13
3712
by: magickarle | last post by:
Hi, I got a pass-through query (that takes about 15 mins to process) I would like to integrate variables to it. IE: something simple: Select EmplID from empl_Lst where empl_lst.timestamp between !! And !! Not sure how to do so (should it be a query in Access or a macro) The connection would be ODBC.
12
11048
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!...
0
7920
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...
0
7849
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...
0
8347
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...
1
7973
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...
0
6626
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...
0
5394
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...
0
3844
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...
1
2358
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
1
1454
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.