form1 and form2

J

james ou

Hi,

I create a form2 in the form1. Can I change some data
of form1 in the form2?

Thanks
 
J

Jeff Yang

Maybe its better to show your source code first,so we can grasp your meaning
better.
 
T

Tom Clement

Yes. One way is to set the Modifiers property of any control you want to
access on form1 to Internal or Public. Make sure you pass a reference to
form1 into form2, then, for example, use the line:
form1.TextBox1.Text = "NewText";
Tom Clement
 
J

james ou

In the form1, have a button to be clicked to create form2,
and in the form2, have a textbox to let user input some
data.Is there some way to let the form1 receive the input
data or to change some variable(data) in the form1 after
user input some data in the form2?
 
T

Tom Clement

Maybe something like this (in C#):

In form2 -- start code --

private form1 m_frmForm1;
internal form1 MyForm1 {set { m_frmForm1 = value;}}

.....
{
...
m_frmForm1.TextBox1.Text = "New Text";
}

form2 -- end code --

now in form1 -- start code --
.....
form2 myForm2 = new myForm2();
myForm2.MyForm1 = this;

form1 -- end code --
 

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