help

H

hossin

Hi to all
I create two win forms,
In form1 have a Label (label1) and Button (bottun1),
In form2: I have one Textbox (textbox2) and one Button (button2)
When click on button1 in form1=„» form2.show(),
I type into textbox2 (in form2 that be shown) ¡§test¡¨,
when click on button2 in form2:
want: form2 have been closed and label1.text fills by textbox2.text
Thanks
 
N

Nicholas Paldino [.NET/C# MVP]

hossin,

You should pass the reference for form1 to form2, and then have form2
set the properties (or call the methods) on form1 which will populate the
texboxes on form 1 before form 2 closes.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi to all
I create two win forms,
In form1 have a Label (label1) and Button (bottun1),
In form2: I have one Textbox (textbox2) and one Button (button2)
When click on button1 in form1=„» form2.show(),
I type into textbox2 (in form2 that be shown) ¡§test¡¨,
when click on button2 in form2:
want: form2 have been closed and label1.text fills by textbox2.text
Thanks
 
P

Peter Duniho

Hi to all
I create two win forms,
In form1 have a Label (label1) and Button (bottun1),
In form2: I have one Textbox (textbox2) and one Button (button2)
When click on button1 in form1=��form2.show(),
I type into textbox2 (in form2 that be shown) “testâ€,
when click on button2 in form2:
want: form2 have been closed and label1.text fills by textbox2.text

Please use a more descriptive subject for your posts.

As far as the question goes, there are any number of ways to do it. One
way (not necessarily the best) is to simply make the textbox2 member
public in form2, have in form1 an event handler subscribed to
form2.Closed, and in the handler assign textbox2.Text to label1.Text.

If you show the second form with ShowDialog(), making the second form
close when you click the button is as simple as setting the DialogResult
property to DialogResult.OK. .NET will do the rest for you. Otherwise,
you can just add a handler for the button in the form class that calls
Close().

Pete
 

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