472,119 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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 13993
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.