Discussion:
showDialog returning the wrong result?
(too old to reply)
old_goat
2010-04-14 12:15:01 UTC
Permalink
I have a simple form, called from another, with a cancel and (equivalent of)
OK button in place. Both buttons have _onClick subs to set their result
status:

Me.DialogResult = Windows.Forms.DialogResult.Cancel
for the cancel button....


Using the following on the parent form,
Dim CPresult As String
CPresult = dlg.ShowDialog.ToString

the result appears to be the opposite?
i.e. the 'OK' button generates a 'cancel' state, the cancel button creates
an 'ok' state.
I know each sub is generating its own status correctly - 2 for the cancel, 1
for the ok.

What am I missing?
OK, I can changed the code to detect it the wrong way, but that's not really
what I want to do.
old_goat
2010-04-15 09:00:01 UTC
Permalink
Slight error in this - sorry!
I found a stray line of code that was switching one of the dialogresults the
wrong way.
I now find that whatever status is reported back to showdialog , the result
is 'OK', as though its actually recording that the call is successful.

Is there a best practice way of capturing the button pressed to close the
window? I've ended up simply using a boolean to do the job instead, which
works fine.
Post by old_goat
I have a simple form, called from another, with a cancel and (equivalent of)
OK button in place. Both buttons have _onClick subs to set their result
Me.DialogResult = Windows.Forms.DialogResult.Cancel
for the cancel button....
Using the following on the parent form,
Dim CPresult As String
CPresult = dlg.ShowDialog.ToString
the result appears to be the opposite?
i.e. the 'OK' button generates a 'cancel' state, the cancel button creates
an 'ok' state.
I know each sub is generating its own status correctly - 2 for the cancel, 1
for the ok.
What am I missing?
OK, I can changed the code to detect it the wrong way, but that's not really
what I want to do.
Loading...