{{date}}
This commit is contained in:
34
Workshop2/Form1.cs
Normal file
34
Workshop2/Form1.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Workshop2
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
//Form2 f2 = new Form2();
|
||||
public Form2 f2;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void showForm2button_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (f2 == null)
|
||||
{
|
||||
f2 = new Form2();// you need to set the textbox in form2 to public
|
||||
f2.textBox1.Text = "Initially Set from form1";// need to ensure if the form is closed it is dereferenced
|
||||
f2.FormClosed += delegate {
|
||||
f2 = null;
|
||||
};
|
||||
}
|
||||
f2.Show();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user