One form to another

W

weird0

How can i access the value of one textbox1.Text in Form1 in Form2.

Form2 is opened right after Form1.

I have worked on c++ but havent worked on c# with Windows applications.
 
P

pigeonrandle

hi,
create a public property (TextBox1Text) in form1 that accesses
TextBox1.Text and pass a reference of form1 to form2.

Then in form2 you can write form1.TextBox1Text = ... or ... =
form1.TextBox1Text

You might consider making the reference to form1 a parameter in the
constructor of form2

HTH,
James.
 
P

Peter Bradley

Both forms are objects, so all you need is a reference to the first form in
your second form. For instance you could have a constructor in Form2 that
goes something like this:

public Form2(Form1 f1) {

....

}

Then in your Form1 instance, you would create a Form2 instance something
like:

Form2 f2 = new Form2(this);

Then you can make f2 visible and away you go.

Something like that, anyway.

HTH


Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top