A program in C #, to transfer data in a form to another form

Uses multiple forms of structures, the need to use the data transfer between the form used in two ways:

method one

1, Designer.cs enter the sub-form, the definition of private Controls Control subform for public

 

 2. In the main window of the program in the instance of child window Form1.cs

 

 3. direct reference to the sub-hull controls

 

Method Two:

Built in the Program inside a structure; which defines a static variable, the variable in FORM1 and FORM2 can be common; direct value assignment like;
a using System;
a using System.Collections.Generic;
a using System.Linq;
a using System.Windows .Forms;

namespace Form1Form2
{
public struct mm
{
public static String m;
};
static class program
{
/// <Summary>
main entry point /// application.
/// </ Summary>
[STAThread]
static void the Main ()
{

Application.EnableVisualStyles ();
Application.SetCompatibleTextRenderingDefault (to false);
the Application.Run (new new the Form1 ());
}
}
}

FORM1
mm.m = textBox1.Text ;
FORM2
textBox1.Text = mm.m;

 

Guess you like

Origin www.cnblogs.com/runningsoybean/p/11549847.html