Newbe DialogResult question

B

Bill Cart

I am trying to work with 2 forms. If I set the ModalResult of a button on
the 2nd form it works OK. If I try to assign the result and then return it
does not return the value I set.

1st Form (calling form)

DeliveryInfo DeliveryFrm = new
DeliveryInfo(Convert.ToInt32(this.uniqueIDTextBox.Text));

DialogResult result;

result = DeliveryFrm.ShowDialog();

if (result == DialogResult.OK)
{
MessageBox.Show("Dialog Result was OK!");
}
else if (result == DialogResult.None)
{
MessageBox.Show("Dialog Result was None!");
}

2nt Form

private void deliveryInfoOkBtn_Click(object sender, EventArgs e)
{
try
{
// code to save dialog info here!

this.deliveryInfoOkBtn.DialogResult = DialogResult.OK;
this.Hide();
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
 
B

Bill Cart

Thanks Mark.

Some times the most productive thing you can do is to get up from your desk
and walk down the hallway. I got so wrapped up in this I could not read the
code anymore.

All I needed was to use DeliveryInfo.ActiveForm.DialogResult =
DialogResult.OK; but I had a hard time getting there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top