Code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace PassBetweenForms { publicpartialclass frmAddress : Form { // add a delegate publicdelegatevoid AddressUpdateHandler(object sender, AddressUpdateEventArgs e); // add an event of the delegate type publicevent AddressUpdateHandler AddressUpdated; public frmAddress() { InitializeComponent(); } privatevoid btnOkay_Click(object sender, EventArgs e) { // this button click event handler will raise the // event which can then intercepted by any listeners // read the textboxes and set the member variables string sNewStreet = txtStreet.Text; string sNewCity = txtCity.Text; string sNewState = txtState.Text; string sNewZipCode = txtZipCode.Text; // instance the event args and pass it each value AddressUpdateEventArgs args =new AddressUpdateEventArgs(sNewStreet, sNewCity, sNewState, sNewZipCode); // raise the event with the updated arguments AddressUpdated(this, args); this.Dispose(); } privatevoid btnCancel_Click(object sender, EventArgs e) { this.Dispose(); } } publicclass AddressUpdateEventArgs : System.EventArgs { // add local member variables to hold text privatestring mStreet; privatestring mCity; privatestring mState; privatestring mZipCode; // class constructor public AddressUpdateEventArgs(string sStreet, string sCity, string sState, string sZip) { this.mStreet = sStreet; this.mCity = sCity; this.mState = sState; this.mZipCode = sZip; } // Properties - Viewable by each listener publicstring Street { get { return mStreet; } } publicstring City { get { return mCity; } } publicstring State { get { return mState; } } publicstring ZipCode { get { return mZipCode; } } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace PassBetweenForms { publicpartialclass frmMain : Form { // default constructor public frmMain() { InitializeComponent(); } privatevoid frmMain_Load(object sender, EventArgs e) { // nothing to do } privatevoid btnSetName_Click(object sender, EventArgs e) { frmID f =new frmID(); // Add an event handler to update this form // when the ID form is updated (when IdentityUpdated fires). f.IdentityUpdated +=new frmID.IdentityUpdateHandler(IdForm_ButtonClicked); f.Show(); } // handles the event from frmId privatevoid IdForm_ButtonClicked(object sender, IdentityUpdateEventArgs e) { // update the forms values from the event args txtFirstName.Text = e.FirstName; txtMiddleName.Text = e.MiddleName; txtLastName.Text = e.LastName; } privatevoid btnSetAddress_Click(object sender, EventArgs e) { frmAddress f =new frmAddress(); // Add an event handler to update this form // when the address form is updated (when AddressUpdated fires). f.AddressUpdated +=new frmAddress.AddressUpdateHandler(AddressForm_ButtonClicked); f.Show(); } // handles the event from frmAddress privatevoid AddressForm_ButtonClicked(object sender, AddressUpdateEventArgs e) { // update the forms values from the event args txtStreet.Text = e.Street; txtCity.Text = e.City; txtState.Text = e.State; txtZipCode.Text = e.ZipCode; } privatevoid btnExit_Click(object sender, EventArgs e) { Application.Exit(); } } } //http://www.codeproject.com/KB/cs/PassDataWinForms.aspx