How to find help button in Windows Forms MessageBox?

I have a window with three buttons: Yes, No, Help:

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

I can determine if there are Yes / No buttons where something like this is clicked:

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

How can I detect that the help button is pressed and execute my own code?

+5
source share
2 answers

You want to handle the Form event HelpRequested. See the example in the help section .

public static DialogResult Show(
    string text,
    string caption,
    MessageBoxButtons buttons,
    MessageBoxIcon icon,
    MessageBoxDefaultButton defaultButton,
    MessageBoxOptions options,
    bool displayHelpButton
)
+5
source

Can I do the same if I'm not in shape? Basically I go the command to call it does not contain any form. I want to display an error message using help for them. In the help button, it will invoke some special actions to help me.

-1
source

All Articles