First you need to change the Modifiers property of the TextBox from private to internal so that it is visible to the main form.

Second, you need a reference to the second form. If you've opened the second form from the main form, then you'll already have a reference though it needs to be saved to a private field of the form rather than a local variable.

private Form2 f2;

// in some method

f2 = new Form2();

f2.Show();

// in some other method

if (f2 != null)

{

TextBox tb = f2.textBox1;

string text = tb.Text;

// do something with text

}

If you haven't opened the second form from the main form, then you could get a reference as you did in the previous thread:

Re: acces textbox from another formPosted
By
mos martin on
16 Mar 2013

another problem..i have a form which shows in some textboxes, the selected row in the dgv, and also i added some picturebox for the next and previous record. i don't know what's wrong..it shows the next record only at the first click, then stops. Here's the code: