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

how to get tha data from form1 to form2 and again in form 1

13
hi,
I oppend first FORM-1 , in FORM-1 click a button and opens FORM-2,
I Entered some text in text box of Form-2, I need the text in FORM -1 again
How to achive this gaol. please help me with sample code.............

thanks
prasad
Nov 24 '08 #1
2 1333
PRR
750 Expert 512MB
Use static variables :
Expand|Select|Wrap|Line Numbers
  1.  public static  class myClass
  2.     {
  3.         public static string mytext;
  4.     }
  5.  
And initialize it on form2 and you can access it on form1...
Nov 24 '08 #2
Curtis Rutland
3,256 Expert 2GB
Static isn't really the way to go here. This is what Properties were made for.

You need to have a public property set in Form2:
Expand|Select|Wrap|Line Numbers
  1. public string TextBoxText
  2. {
  3.   get { return textBox1.Text; }
  4. }
renaming it and changing the name of the textbox as necessary.

Then you should be able to get the information from it in form1, after you call it:
Expand|Select|Wrap|Line Numbers
  1. Form2 f2 = new Form2();
  2. f2.ShowDialog();
  3. string txt = f2.TextBoxText;
Nov 24 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Casey | last post by:
Yeah, I know this question was asked by someone elselike 2 weeks ago. But I need some additional help. I have a program I'm developing, and multiple different forms will be opened. For now though,...
1
by: nic | last post by:
Hi I have two forms form1 and form2. I am trying to get all the data entered in form1 to be updated to the table on an event. ie. when I click the button to load form2, I need the data from...
1
by: John | last post by:
My data has 10 accounts. Two forms are opened simultaneously. Form1 is unbound and displays three records: Account Quantity 101 17 104 25 107 ...
15
by: http://www.visual-basic-data-mining.net/forum | last post by:
Does anyone have any idea how to transferring data from TextBox1 in form1 to textBox2 in form2..... That means after i fill in any data in textBox1 and click Next button... It will bring me to...
7
by: AMP | last post by:
Hello, I have this in form1: namespace Pass { public partial class Form1 : Form { public Form2 form2; public Form1() {
7
by: Jason | last post by:
Hello I've got a very simple C# app, that has a datagrid, a text box, and a button which when clicked opens a second form... Form2 frm2 = new Form2(); frm2.Show(); When I place a datagrid,...
5
by: Boki | last post by:
Hi All, There are two forms, when some click happen, it fires to set form2's viable as enable. The form2 is for user to input some text and then the data need to be collected into form1's...
7
by: Boki | last post by:
Hi All, I can't pass data to another form: in form2: private void button1_Click(object sender, EventArgs e) { Form1 form_copy = new Form1();
8
by: AshParr | last post by:
Hi all, I have 2 forms, "Form1" & "Form2", i have a button that currently opens form2 from form1 and then hides itself: Form2 form2 = new Form2(); form2.show; this.Visible = False; and...
7
by: gamernaveen | last post by:
I've been busy coding a signup system with PHP. There are 2 forms , form1 and form2. form1 contains: Name , Age , form 2 contains Username , Password , Repeat Pass , Email I use POST method...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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?

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.