开发者

How to detect Help button press in Windows Forms MessageBox?

开发者 https://www.devze.com 2022-12-22 03:37 出处:网络
I have a message box with 3 buttons: Yes, No, Help: var result = MessageBox.Show(\"text\", \"title\", MessageBoxButtons.YesNo,

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 开发者_C百科pressed and execute my own code?


You want to handle the Form's HelpRequested event. See the example in the help topic.

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

精彩评论

暂无评论...
验证码 换一张
取 消