How do I detect that a user clicked on the Ok button ?

J

Joe Abou Jaoude

In a PPC app, how do I detect that a user clicked on the Ok button ?

The VisibleChanged Event would have done the job, however unfortunately,
it's not supported by the compact framework

The Deactivated event isn't accurate since it could be triggered by
other things like a messagebox for example, and since the Visible
property will always be true in the Deactivated EventHandler.

So is there an event to detect that the Ok button was pressed, or should
I write a workaround code ?

Regards
 
F

Frederic

I have made it the following way (in my case, I have a Cancel button in
the form, in addition to the title bar OK button) :

- in the Form.ShowDialog method, set the DialogResult to all other
buttons closing the form (e.g. Cancel.DialogResult =
DialogResult.Cancel)

- in the Closing event callback, if the DialogResult is not equal to
any of the buttons' DialogResults, then the window is being closed by
the ok button.

Hope this helps,
Frédéric


Joe Abou Jaoude a écrit :
 

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