Add hyperlink to Messagebox c#

Asked

Viewed 557 times

2

It is possible to customize the MessageBox.Show("http://www.google.com/"); so that this link is a hyperlink and when I click open a browser?

The only possibility really would be to create a new form?

2 answers

2


There are two options:

  1. Create a form new to simulate a MessageBox

    In this case, it is only necessary to create a form normal, add a label for be the link and add the event to click in it.

    Ex.:

    private void labelLink_Click(object sender, EventArgs e)
    {
        Label lb = (Label)sender;
        Process.Start(lb.Text);
    }
    
  2. Use one of the buttons MessageBox to open the link.

    var result = MessageBox.Show("Clique em ok para ir para http://www.google.com");
    
    if(result == DialogResult.Ok)
    {
        Process.Start("http://www.google.com");
    }
    

0

I used so >>

var tituloDaMensagem = "Aviso do Robô - COD. 0025";
var mensagem = $ "Erro ao verificar o laçamento. Clique em ok para ver como solucionar o erro";
MessageBoxButton buttons = MessageBoxButton.YesNoCancel;
MessageBoxResult result;
result = MessageBox.Show(mensagem, tituloDaMensagem, buttons, MessageBoxImage.Error);
if (result == MessageBoxResult.Yes) {
  Process.Start("http://www.suaurl.com");
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.