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

How pass variable from one form to the next in Win app?

I have a form open and when a user clicks a button I do a frmNew.Show() and
this.Hide. But I have a value that I need to pass to the new form. How can
I do this, please?

Thanks very much,
Ron
Mar 30 '06 #1
4 1519
There are a few ways to do this. Here are a couple that come to mind.
(1) Create a property exposed from the second form and push the value into
this property before showing the form.
(2) Create a constructor overload for the second form and pass the value in
when creating the instance of the form.

--
Tim Wilson
..NET Compact Framework MVP

"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
I have a form open and when a user clicks a button I do a frmNew.Show() and this.Hide. But I have a value that I need to pass to the new form. How can I do this, please?

Thanks very much,
Ron

Mar 30 '06 #2
Hello Ronald,

Create Singleton object, where keep you data (like Cache), and use in from
different forms

RC> I have a form open and when a user clicks a button I do a
RC> frmNew.Show() and this.Hide. But I have a value that I need to pass
RC> to the new form. How can I do this, please?
RC>
RC> Thanks very much,
RC> Ron
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Mar 30 '06 #3
Michael Nemtsev <ne*****@msn.com> wrote:
Create Singleton object, where keep you data (like Cache), and use in from
different forms


Unless the value really *is* a logical singleton, I'd advise against
using a singleton to store it. We don't use singletons to store all
data that needs to flow between other objects - why should forms be any
different? I'd go with Tim's answer.

I often find it interesting how many questions come up about forms
which suggest that people think of them in a totally different way to
other classes. I wonder whether it's the designer aspect of things -
perhaps if people wrote forms from scratch, they wouldn't make as much
mental distinction between them.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 30 '06 #4
Hello Jon Skeet [C# MVP],

J> Michael Nemtsev <ne*****@msn.com> wrote:
J>
Create Singleton object, where keep you data (like Cache), and use in
from different forms

J> Unless the value really *is* a logical singleton, I'd advise against
J> using a singleton to store it. We don't use singletons to store all
J> data that needs to flow between other objects - why should forms be
J> any different? I'd go with Tim's answer.

Agree, but it depends on app. For example in one day we can end up that we
need to give web access to our app and to show this data.
I just gave more abstract solution, but again, w/out knowing more about data
we can't predict where and how it will be used
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Mar 30 '06 #5

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

Similar topics

3
by: edward hage | last post by:
Hello , I want to pass some $_SESSION data to another page. I can pass PHPSESSID along using echo '<br /><a href="page2.php?' . SID .. '">page 2</a>'; However, I want to fill in a table...
3
by: C-man | last post by:
Hey, I need to know if and how I would pass a variable from php to an html document. I know how to go from a form to php but is there a way to go back? Thanks
6
by: HH | last post by:
I'm learning to design web applications with php, mysql, and apache from a book. I copied a sample application called guestbook 2000 that came with the CD in the book to my htdocs folder, but...
1
by: weiwei | last post by:
Hi all I am having trouble, let's say, I have a form text field, and I want to pass it to the next page, however, I don not want to use submitted button, instead I want to have a variable in link...
2
by: umashd | last post by:
Hi, I am doing a web based project for my graduation. I studied bit of java for backend processesing and javascript for the client. Here is the scenario. In the FORM, I use INPUT TYPE=text...
4
by: Phillip Vong | last post by:
I'm a newbie using VS2005 to learn and test. I'm testing against the Northwind DB. I created a simple variable called "myVariable" and I assigned it the character "c". I want my SQL query to use...
10
by: mike4722 | last post by:
I wish to have the form to be able to automatically select the radio button based on the logic of HTML/php variable. example show below: javascript: function autoForm(value) { var myForm =...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
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....
9
by: JRough | last post by:
I tried to pass the $result from a mysql_query in a url like this line Header("Location:clm_historyXL.php?_result=".$result); but on the redirect location clm_history.php page I get an error on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...

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.