namespace Main_Forms
{
public partial class Form1 : Form
{
Form2 frm2;
Sub_From.SubForm2 Sfrom;
public string answer;
public Form1()
{
InitializeComponent();
button2.Enabled = false;
textBox1.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
button2.Enabled = true;
textBox1.Enabled = true;
frm2 = new Form2();
if(frm2.ShowDialog()==DialogResult.Yes)
{
Sfrom = new Sub_From.SubForm2();
Sfrom.FormClosed += new FormClosedEventHandler(SubForm_FormClosed);
Sfrom.Show(this);
}
}
private void button2_Click(object sender, EventArgs e)
{
if (Sfrom != null)
{
Sfrom.Close();
//Sfrom.Dispose();
Sfrom = null;
}
}
private void SubForm_FormClosed(object sender, FormClosedEventArgs e)
{
textBox1.Text = Sfrom.valueans;
Sfrom.Dispose();
Sfrom = null;
}
}
}
============================================================================
namespace Main_Forms
{
public partial class Form2 : Form
{
//Sub_From.SubForm2 Sform;
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Yes;
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
===========================================================================
namespace Sub_From
{
public partial class SubForm2 : Form
{
public string valueans
{
get { return textBox1.Text; }
}
public SubForm2()
{
InitializeComponent();
}
}
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE