CodePudding user response:
https://bbs.csdn.net/topics/360140208? List=lzCodePudding user response:
After opening the new window content is to synchronize with the original window contents updateCodePudding user response:
///window 1
Private delegate void delegateRefMessage (string MSG);
Private event delegateRefMessage RefMsg;
Private void SetText (string MSG)
{
The string content=richTextBox1. Text. The Trim ();
}
Private void button1_Click (object sender, EventArgs e)
{
Form2 f2=new Form2 ();
RefMsg +=new delegateRefMessage (f2. SetTextFromOther);
F2. The Show ();
}
Private void richTextBox1_TextChanged (object sender, EventArgs e)
{
If (RefMsg!=null) RefMsg (richTextBox1. Text. The Trim ());
}
///window 2
Public void SetTextFromOther (string STR)
{
This. RichTextBox1. The Clear ();
Enclosing richTextBox1. Text=STR;
}
CodePudding user response:
Constructor, entrust, eventCodePudding user response:
In the new window object of the Tag to add data, and then read it out into a new window,NewForm nf=new newForm ();
Nf. Tag=12;
Nf. The Show ();
CodePudding user response:
Use event subscription mechanism, click on the button after the triggerCodePudding user response:
If the two Windows are linked (2) window 1 know window, define attributes directly, assignment,If two unrelated window, to send messages between the need to use the commission,
CodePudding user response:
Constructor, entrust, eventCodePudding user response:
The simplest method isNewform nf=new newform (string value)
Nf. Your control. The text=value;
CodePudding user response:
Static global variables, two Windows with casually, as follows:Public static Color background Color=Color. Wheat;
Public static bool application load success=false;
CodePudding user response:
The