I have teo form form1 and form2 i want to pass form1 textbox1 text in form2 textbox1.text whae i click a button of form1.(Its for windows application)

Plz give me some help......

You do:

//form1:
 public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2(textBox1.Text);
            f2.Show();
        }
    }

//form2:

    public partial class Form2 : Form
    {
        public Form2(string value)
        {
            InitializeComponent();
            textBox1.Text = value;
        }
    }

If you want to pass the value from form1 to form2 when the form2 is opened, you can use this kind of code:

//form1:
 public partial class Form1 : Form
    {
        Form2 f2;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (f2 == null)
                f2 = new Form2();
            f2.ValueFromForm1(textBox1.Text);
            f2.Show();
        }
    }

//form2:
 public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        public void ValueFromForm1(string value)
        {
            textBox1.Text = value;
        }
    }

Mijja it it also work in which u hd solved my problem of dend doctor_id and name in another form,?????

Thanks mitja its working.........

Plz, make this thread has solved if u find ur answer.

Man, again and again. One question for 2 weeks now. Please get some books and start learing by your self. We cannot teach you all here. We are here to help, not to teach ppl.
I wont answer on these kind of threads any longer. I think I gave given you more then enough, and if you still havent figured it out by now, this is not my problem. Sorry for sounding a bit harsh, but I simply dont like the way you are "forcing" us to do all the code you need instead of you.
bye

I have 2 textbox in form 1 and have 2 ok button also...
When i write in my textbox1 in form1, the text will appear in textbox in form2, and when i write text in form 2 the text will appear in textbox1 in form1 or vise versa, Then when i write in textbox2 in my form1, the text appear in textbox in form 2 but when i edit the text that appear and press ok, it appear in textbox1 , my problem is i want to appear it in textbox2 not in textbox1...??HElp me please

commented: do dsame thing you did in form1 to form2 amd now it should be textbox2 +0

i want to pass a value from text box of class(not in form) in wpf to another class ..is it possible , if it is how to do that.

its not working. the textbox1 in the form 2 says that it does not contain in the context.

why its not working in me? The textbox1 in form2 says that it does not contain in the current context, but it seems that ValueFromForm1 calls it from form1.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.