Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have develop windows application.
In that i want to pass some data from one form to other from.
How to do this.
If any one have idea pls suggest it.
Thanks in advance.
Posted

 
Share this answer
 
v3
Comments
Mohamed Mitwalli 11-Sep-12 8:43am    
5+
__TR__ 11-Sep-12 12:13pm    
Thanks.
Passing Variable from one form to another form in windows application:
In first form Under Button click wirte like this

C#
private void button1_Click(object sender, EventArgs e)
       {
           Display d = new Display(textBox1 .Text );
           d.Show();
       }

Then In secound Form write like this
C#
public partial class Display : Form
    {
        string str;// declare string to strore value

//constructor to load value
        public Display(string txt)
        {
            InitializeComponent();
            str = txt;
        }
//form load 
        private void Display_Load(object sender, EventArgs e)
        {
            label1.Text = str;
        }
    }
 
Share this answer
 
Comments
Mohamed Mitwalli 11-Sep-12 8:45am    
5+
Have a look:
Pass Data from One Form to Another Form[^]

If you are using ID on all form, you can simply use static property in your class file program.cs
Something like this:
C#
public static Int ID
        {
            get;
            set;
        }
 
Share this answer
 
Comments
Mohamed Mitwalli 11-Sep-12 8:44am    
5+
Prasad_Kulkarni 12-Sep-12 0:15am    
Thank you Mohamed!
Hi,
Check this link
how to pass values from child form to parent form[^]
Best Regards
M.Mitwalli
 
Share this answer
 
Nice and Easy...

C#
var yourForm1=System.Windows.Forms.Application.OpenForms["Form1"] as Form1;
yourForm1.textBox1.Text="Text From another window";
 
Share this answer
 
v2
you use query string like
On First page
C#
string j="Himanshu";
Response.Redirect("BulkUpdate.aspx?id="+j+"");

On second Page
C#
string u=  Request.QueryString["id"].ToString();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900