winforms Show Help for MessageBox


Example

You can provide help for message box in different ways. You can configure a MessageBox to show a Help button or not. Also you can configure MessageBox in a way that when the user requests for help by click on Help button or by pressing F1, it show a CHM file or navigate to a URL or perform a custom action. Here are some examples in this topic.

In all below examples, the MessageBox would be like this:

MessageBox with Help Button

Show a CHM file and navigate to a keyword (index)

MessageBox.Show("Some Message", "Title", MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question, MessageBoxDefaultButton.Button3, 0,
    "help.chm", HelpNavigator.KeywordIndex, "SomeKeyword");

Show a CHM file and navigate to a topic

MessageBox.Show("Some Message", "Title", MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question, MessageBoxDefaultButton.Button3, 0,
    "help.chm", HelpNavigator.Topic, "/SomePath/SomePage.html");

Show a CHM file and navigate first help page in table of contents

MessageBox.Show("Some Message", "Title", MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question, MessageBoxDefaultButton.Button3, 0,
    "help.chm");

Open default browser and navigate to a URL

MessageBox.Show("Some Message", "Title", MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question, MessageBoxDefaultButton.Button3, 0,
    "http://example.com");

Perform custom action on when pressing Help Button or F1 Key

In this case you should handle HelpRequested event of parent of MessageBox and perform custom operation:

private void Form1_HelpRequested(object sender, HelpEventArgs hlpevent)
{
    // Perform custom action, for example show a custom help form
    var f = new Form();  
    f.ShowDialog();
}

Then you can show the MessageBox with Help button:

MessageBox.Show("Some Message", "Title", MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question, MessageBoxDefaultButton.Button3, 0, true);

Or show it without Help button:

MessageBox.Show("Some Message", "Title", MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question, MessageBoxDefaultButton.Button3, 0, false);