Partager via


Guide pratique pour afficher une page web à partir d’un contrôle LinkLabel Windows Forms (Visual Basic)

Cet exemple montre comment afficher une page web dans le navigateur par défaut lorsqu’un utilisateur clique sur un contrôle Windows Forms LinkLabel .

Exemple :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles MyBase.Load
    LinkLabel1.Text = "Click here to get more info."
    LinkLabel1.Links.Add(6, 4, "www.microsoft.com")
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal _
e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles _
LinkLabel1.LinkClicked
    System.Diagnostics.Process.Start(e.Link.LinkData.ToString())
End Sub

Compilation du code

Cet exemple nécessite :

  • Un Windows Form nommé Form1.

  • Un contrôle LinkLabel nommé LinkLabel1.

  • Connexion Internet active.

Sécurité du .NET Framework

L’appel à la Start méthode nécessite une confiance totale. Pour plus d’informations, consultez SecurityException.

Voir aussi