I want to display a link to help in a message box. By default the text is displayed as a non-selectable string.
-
2Sounds like two requests. Use a Form instead of MessageBox. – Hans Passant Dec 02 '09 at 16:01
5 Answers
One option is display the url in the message box, along with a message and provide the help button that takes you to that url:
MessageBox.Show(
"test message",
"caption",
MessageBoxButtons.YesNo,
MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1,
0, '0 is default otherwise use MessageBoxOptions Enum
"http://google.com",
"keyword")
Important to note this code cannot be in the load event of the form, the Help button will not open the link.

- 5,492
- 2
- 36
- 65

- 2,618
- 5
- 25
- 24
-
1Thanks, creative solution that in my case will be sufficient. Really appreciate it. (Upvotes to everyone) – Jeff Dec 02 '09 at 16:09
-
1Note that the `"keyword"` will be appended after a # to the URL as an anchor reference. I.e. http://google.com#keyword – Daniel Ballinger Sep 30 '14 at 00:34
-
7Clicking on the help button with this code in C# doesn't do anything – reggaeguitar Jan 15 '16 at 18:20
You can use the LinkLabel
control on your own Form
for this. Unfortunately, the MessageBox
form cannot be customized in this way, so you would need to create your own Form
to mimic the MessageBox
for your purposes.

- 61,417
- 20
- 137
- 189
MessageBox won't do that. You'll either need to use the TaskDialog (introduced in Vista) or create your own dialog.
--Edit--
There are ways to fake the task dialog on XP. There are a few articles on CodeProject.com that I've used in the past.

- 7,638
- 3
- 39
- 60
You have to create your own form, instead of the built-in MessageBox, and you can use a LinkLabel
on it.
However on the built-in MessageBox a Help button could be displayed among the buttons.

- 5,788
- 1
- 25
- 24
You could use some custom code with LinkLabel
like this:
if (hyperLinks != null)
{
foreach (var link in hyperLinks)
{
var linkLabel = new LinkLabel();
linkLabel.Text = link;
linkLabel.Width = WhateverParentPanelYouHave.Width;
linkLabel.Click += LabelClicked;
WhateverParentPanelYouHave.Controls.Add(linkLabel);
}
}
Where hyperLinks
is a list of strings for your links.
Then for your LabelClicked
handler:
private async void LabelClicked(object sender, EventArgs e)
{
var linkLabel = (LinkLabel) sender;
var path = linkLabel.Text;
try
{
await Task.Run(() => Process.Start($@"{path}"));
}
catch (Exception ex)
{
MessageBox.ShowMessage(ex.Message, @"An Error Has Occurred");
}
}
Keep in mind, this is your own form with the LinkLabel
control added to it. You'll have to inherit from Form
and use the ShowDialog()
method to display your form with all your controls added to it.

- 4,658
- 2
- 34
- 47