I made a form2 that shows and there are buttons which return DialogResult but I have no idea why this doesn't work:
Form1:
private void buttonEvent_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
if (form2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
labelEvent.Text = hEvent.GetName; //Breakpoint here but it doesn't stops!
}
Form2:
String Name;
public String GetName
{
get { return Name; }
}
private void button1_Click(object sender, EventArgs e)
{
button1.DialogResult = DialogResult.OK;
this.Close();
}
I think you should use
private void button1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
Just set button1 to the AcceptButton on the Form object. You won't need a single line of code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With