form problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form1. It has a textbox1. I created another form2. I want to grab
the value of textbox1 of form1 into form2. I am doing like this
In form2

form1 myform = new form1();
string mystr = myform.textbox1.Text;

But it is giving me follwing error.
form1.txtNewMake' is inaccessible due to its protection level

Where is the problem.
 
seema said:
I have a form1. It has a textbox1. I created another form2. I
want to grab
the value of textbox1 of form1 into form2. I am doing like this
In form2
form1 myform = new form1();
string mystr = myform.textbox1.Text;
But it is giving me follwing error.
form1.txtNewMake' is inaccessible due to its protection level
Where is the problem.

You can fix this by selecting "txtNewMake" in the Designer and
changing its Modifier property to Public, so that code outside the
form can see it. But you should probably expose a property from that
form giving the value that was typed into the text box: it's more
future-proof and it will make sure you can't set unrelated properties
on that control.

Eq.
 
Back
Top