C# 如何在 MessageBox.show 中创建超链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14819426/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 13:06:35  来源:igfitidea点击:

How to create Hyperlink in MessageBox.show?

c#winformshyperlinkmessagebox

提问by

I have tried creating a hyperlink in MessageBox in this way:

我曾尝试以这种方式在 MessageBox 中创建超链接:

MessageBox.Show(
    "test message",
    "caption",
    MessageBoxButtons.YesNo,
    MessageBoxIcon.Information,
    MessageBoxDefaultButton.Button1,
    0,
    **"http://google.com"**,
    "Keyword"
);

Note: The Above code was actually "chosen as a answer" in an another question https://stackoverflow.com/a/1833877/2046417,but I don't know why its not working for me. I am getting error at keyword(Error 3 The * or -> operator must be applied to a pointer C:\Users\kiriti\Documents\Visual Studio 2010\Projects\TailorApplication_3\TailorApplication_3\Form1.cs 359 140 TailorApplication_3)

注意:上面的代码实际上是在另一个问题https://stackoverflow.com/a/1833877/2046417 中“选择作为答案” ,但我不知道为什么它对我不起作用。我在关键字上出错(Error 3 The * or -> operator must be applied to a pointer C:\Users\kiriti\Documents\Visual Studio 2010\Projects\TailorApplication_3\TailorApplication_3\Form1.cs 359 140 TailorApplication_3)

采纳答案by TaRDy

I tried playing around with the code and found a solution to my own question.

我尝试使用代码并找到了我自己问题的解决方案。

if (MessageBox.Show(
        "test", "Visit", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk
    ) == DialogResult.Yes)
{
    System.Diagnostics.Process.Start("http://www.google.com");
}

Works great! :)

效果很好!:)

回答by TaRDy

The example given is for VB, if you remove the ** from the URL it will show the message box and take you to that URL when the help button is clicked.

给出的示例适用于 VB,如果您从 URL 中删除 **,它将显示消息框并在单击帮助按钮时将您带到该 URL。

For more information on the parameters of this call, see:

有关此调用参数的更多信息,请参阅:

http://msdn.microsoft.com/en-us/library/ww6cfk80.aspx

http://msdn.microsoft.com/en-us/library/ww6cfk80.aspx