Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Utilities » Downloads
 
Add your own
alternative version

Passing Data Between Forms

, 16 May 2006
This article is aimed at providing some simple methods for passing data between forms in Windows applications
PassData.zip
PassData_Delegates
App.ico
bin
Debug
PassData_Delegates.exe
PassData_Delegates.csproj.user
PassData_Constructor
App.ico
bin
Debug
PassData_Constructor.exe
PassData_Constructor.csproj.user
PassData_Object
App.ico
bin
Debug
PassData_Object.exe
PassData_Object.csproj.user
PassData_Properties
App.ico
bin
Debug
PassData_Properties.exe
PassData_Properties.csproj.user
Pass_Data_Berween_Forms_demo.zip
App.ico
Release
PassData_Delegates.exe
PassData_Delegates.csproj.user
App.ico
Release
PassData_Constructor.exe
PassData_Constructor.csproj.user
App.ico
Release
PassData_Object.exe
PassData_Object.csproj.user
App.ico
Release
PassData_Properties.exe
PassData_Properties.csproj.user
Pass_Data_Between_Forms_demo.zip
App.ico
PassData_Delegates.exe
PassData_Delegates.csproj.user
App.ico
PassData_Constructor.exe
PassData_Constructor.csproj.user
App.ico
PassData_Object.exe
PassData_Object.csproj.user
App.ico
PassData_Properties.exe
PassData_Properties.csproj.user
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace PassData_Object
{
	/// <summary>
	/// Summary description for Form2.
	/// </summary>
	public class Form2 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		public Form1 frm1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form2()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(60, 31);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(176, 32);
			this.label1.TabIndex = 1;
			this.label1.Text = "label1";
			// 
			// Form2
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(296, 94);
			this.Controls.Add(this.label1);
			this.Name = "Form2";
			this.Text = "Form2";
			this.Load += new System.EventHandler(this.Form2_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void Form2_Load(object sender, System.EventArgs e)
		{
			label1.Text=((Form1)frm1).textBox1.Text;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Thiagarajan Alagarsamy
Web Developer
India India
Thiagu is living in Bangalore, India. He has started coding when he was 12 years old. His native is Madurai, a historic city in south India. He loves to code in C#. He frequents code project when he is not coding. Thiagu loves reading Dan Brown and Michael Crichton novels. He is very much interested in Artificial Intelligence (AI). To view his blog - http://csharpnet.blogspot.com

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 16 May 2006
Article Copyright 2006 by Thiagarajan Alagarsamy
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid