Frank,
According to the Microsoft's documentation (I should know better by
now) it should be sufficient just to use:
Form.DialogResult = DialogResult.OK
Form.Hide()
What documentation??? Remember documentation can be wrong or misleading...
You actually do not need the Form.Hide!
All you need in VS.NET 2002 & VS.NET 2003 is:
Private Sub btnSave_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSave.Click
Me.DialogResult = DialogResult.OK
End Sub
However I prefer setting the Button.DialogResult & Form.AcceptButton, then I
do not need the event handlers. Which also works in both VS.NET 2002 &
VS.NET 2003.
Can you post (if its small) or email me a complete sample of what you are
doing, I am not able to recreate what you describe, given the information
you posted.
IMPORTANT: Within in your EntryForm are you setting DialogResult any place
other then the button's click event handlers? Such as the Closed event?
The only way I was able to recreate what you are seeing is by adding the
following to my form:
Private Sub AboutDialog_Closed(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Closed
Me.DialogResult = DialogResult.Cancel
End Sub
Which definitely is not needed, as the form automatically returns Cancel if
you click the Close button!
Hope this helps
Jay
Frank Maxey said:
I have the 2002 version.
I had already tried setting the buttons that you outline below, with
no success. I found it was easier and more straightforward to create
another property for the form.
According to the Microsoft's documentation (I should know better by
now) it should be sufficient just to use:
Form.DialogResult = DialogResult.OK
Form.Hide()
I think I'll just stick with writing my own properties explicitly. At
least I can be certain how they work.
Thanks for the reply.
Frank Maxey
(e-mail address removed)
(Remove 'KeinSpam' to reply to my e-mail address)
"Jay B. Harlow [MVP - Outlook]" <
[email protected]> wrote in message
Frank,
Normally what I do is what William Ryan was asking about.
On the DialogForm form:
Form.AcceptButton = buttonSave
Form.CancelButton = buttonCancel
On the buttonSave button:
Button.DialogResult = DialogResult.Ok
On the buttonCancel button:
Button.DialogResult = DialogResult.Cancel
The Form will automatically handle setting Form.DialogResult & calling
Form.Hide when you click either button, or press the Enter or Cancel key.
Alternatively, if you set Form.DialogResult within your event handler, Hide
is automatically called for you.
Is this with VS.NET 2002 or VS.NET 2003? I could not replicate you problem
with VS.NET 2003.
Hope this helps
Jay
(since
I