setting DialogResult issue

G

Guest

Hello All

I have created a form to act like a dialog box. In this form I have a button ... when i click the butto
i set the dialogresult value to

Me.DialogResult = DialogResult.O

the problem is when i click the button and set the dialogResult to DialogResult.O
the calling form condition of

Dim tForm As TestForm = New TestFor
tForm.ShowDialog(
If (t.ShowDialog = DialogResult.OK) The
MessageBox.Show("in here"
End I

does not work! It only works when I click the button on the dialog form twice
Is there a bug in setting the DialogResult

thanks
ada
 
A

Alex Feinman [MVP]

Did you also set the button's DialogResult property?

Adam said:
Hello All,

I have created a form to act like a dialog box. In this form I have a
button ... when i click the button
 
G

Guest

where would I do that?

----- Alex Feinman [MVP] wrote: -----

Did you also set the button's DialogResult property?
 
G

Guest

i set the button's DialogResult property to DialogResult.OK .... it did not work

----- Alex Feinman [MVP] wrote: ----

System.Windows.Forms.Button has DialogResult propert
 
A

Alex Feinman [MVP]

Adam,

I don't see a problem. The following code:

Form1.cs:
Form2 frm = new Form2();
DialogResult res = frm.ShowDialog();
MessageBox.Show(res.ToString());


Form2.cs:
DialogResult = DialogResult.Cancel;

displays "Cancel" as expected.
 
G

Guest

Try this

Dim frm2 As New Form
If frm2.ShowDialog() = DialogResult.OK The
Messagebox.Show("In here"
Els
Messagebox.Show("Out here"
End If
 

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