form problem

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.
 
P

Paul E Collins

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.
 

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