views:

214

answers:

2

I have a message box with 3 buttons: Yes, No, Help:

var result = MessageBox.Show("text", "title",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning,
                MessageBoxDefaultButton.Button1,
                true);

I can detect if Yes/No buttons where clicked something like this:

if(result == DialogResult.Yes)
    // some actions

How I can detect that Help button was pressed and execute my own code?

+2  A: 

You want to handle the Form's HelpRequested event. See the example in the help topic at http://msdn.microsoft.com/en-us/library/szwxe9we.aspx.

public static DialogResult Show(
    string text,
    string caption,
    MessageBoxButtons buttons,
    MessageBoxIcon icon,
    MessageBoxDefaultButton defaultButton,
    MessageBoxOptions options,
    bool displayHelpButton
)
AMissico
A: 

Except that doesn't work - not for me, anyway. I handle the underlying Form's HelpRequested event like the article says, and the event never gets called.

Trevortni
Stack Overflow is not a discussion forum, it's a Question and Answer site. Repost this as a new question, but link back to this question stating that the accepted answer doesn't work for you. Post your code as well, there might be an error in it which someone could spot.
ChrisF