473,730 Members | 4,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14097
In article <uN************ **@TK2MSFTNGP03 .phx.gbl>, fr********@gmai l.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.ShowDialo g() == DialogResult.OK )
{
if (form.ReturnDat a = "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 HandleShowForm2 Click(Object sender, EventArgs e) {
Form2 form = new Form2();
if (form.ShowDialo g() == DialogResult.Ca ncel) {
return;
}

Object yourResult = form.DataSource ;

}
}
Feb 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1715
by: RubiconXing | last post by:
Hi All Beginner question - please be patient with me :-) I am new to c#. If one creates a child modal (and also non-modal) form what is the best way of returning the collected data back to the calling form? For example, say off of my main form I launch a modal dialog box that gets the username and password what is the best way of passing that data back? The info has to go into an object eventually so I can
0
1516
by: notalent | last post by:
I'm having a problem with a very basic program. I'm creating a app in Visual Studio (2003) C# to zip up a collection of specified files & directories and save them to a certain location. I have a checkedListBox that holds all the directories and files that I want saved. I have two buttons (One for selecting file & one for directory) that are hooked to a openFileDialog and folderBrowserDialog. When a new file or dir is selected, it...
2
11033
by: Xarky | last post by:
Hi, I have the main form, where from one of the methods, an instance of another form is created. On the second form I have to fill some data and be submitted by a button click. The data to be entered is to be returned to the main form. A sample of code of my problem. // main Windows Form
3
17345
by: VMI | last post by:
In my Windows application, the main Form (Form_Main) calls a small Form (Form_X) that checks a file. Basically, I pass the name of the file through frmX's constructor and then I display it with ShowDialog(). In the constructor, I call the method that runs the validation process. Is it possible that, once this process (which returns a bool) is finished, that it returns this value to the main Window ? Baically, I want to pass the return...
2
24884
by: VMI | last post by:
I have one Windows Form form1 with a button, and when I press that button, it'll display another Form form2 whose only purpose is for the user to enter a path. Is it possible for form2 to return that string value back to form1, similar to the MessageBox? Thanks.
9
14068
by: Ale K. | last post by:
What's the best way to make a form return a value.... i want to try to avoid using module variables for doing this... Thanks. Alex.
7
15131
by: =?Utf-8?B?aXdkdTE1?= | last post by:
hi, im attempting to create an intellisense type form and have hit a roadblock. I need the form to return (like the ShowDialog method returns the dialog result) the value that was selected when the form closes. however, i cannot just create a method that shadows ShowDialog and return it that way because the form needs to close when the user clicks elsewhere on the screen, or Alt-Tabs away from the window. i already have the code to close...
7
16290
by: pooba53 | last post by:
I am working with VB .NET 2003. Let's say my main form is called Form1. I have to launch a new form (Form2) that gathers input from the user. How can I pass variable information back to Form1 before calling the Me.close() on Form2? -Stumped
2
1902
by: Macias | last post by:
Hi, Please tell me how I can exchange data between two forms. My main form is Form1, and I display a new form something like this: private void Settings_Click(object sender, EventArgs e) { using (Form Setings_form = new settings()) { Setings_form.ShowDialog(); } }
0
8770
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9442
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9301
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9229
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6725
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4543
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3257
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.