469,365 Members | 1,840 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,365 developers. It's quick & easy.

How return data for a Showdialog()

Hi, I make a a program with two Form, I call Form2 as showdialog()

I Would like receive data when Form2 is closed, how make that?. How return
data when the form is closing or closed?.

Thanks in advance.

Freddy Coal

Feb 26 '07 #1
2 13812
In article <uN**************@TK2MSFTNGP03.phx.gbl>, fr********@gmail.com
says...
Hi, I make a a program with two Form, I call Form2 as showdialog()

I Would like receive data when Form2 is closed, how make that?. How return
data when the form is closing or closed?.
The form may be closed (i.e. not visible), but the object still remains
in memory. Just create some public properties on Form2 with your return
information and you can access them in the calling form:

Form2 form = new Form2();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ReturnData = "itworks")
...
}

--
Patrick Steele
http://weblogs.asp.net/psteele
Feb 26 '07 #2
public class Form2 : Form {
private Object _DataSource;
public Object DataSource {...}
}

public class Form1 : Form {
public void HandleShowForm2Click(Object sender, EventArgs e) {
Form2 form = new Form2();
if (form.ShowDialog() == DialogResult.Cancel) {
return;
}

Object yourResult = form.DataSource;

}
}
Feb 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by RubiconXing | last post: by
reply views Thread by notalent | last post: by
3 posts views Thread by VMI | last post: by
2 posts views Thread by VMI | last post: by
7 posts views Thread by =?Utf-8?B?aXdkdTE1?= | last post: by
7 posts views Thread by pooba53 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.