473,394 Members | 1,640 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,394 software developers and data experts.

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 2920
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.com

"Mikey" <an*******@discussions.microsoft.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.com

"Mikey" <an*******@discussions.microsoft.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*******@discussions.microsoft.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.com

"Mikey" <an*******@discussions.microsoft.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
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...
11
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
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...
3
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...
3
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
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...
17
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...
14
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...
13
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...
12
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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
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
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
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...

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.