0

I am having trouble making the link open a web browser and going to the website can someone please show me what to do in the linkClicked.

        private void agricultureLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
        }
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by lxXTaCoXxl
0

heres what I have, but its not opening a new window or anything

    private void scienceLink_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
    {
        try
        {
            VisitLink();
        }
        catch (Exception ex)
        {
            MessageBox.Show("Unable to open link that was clicked.");
        }
    }
    private void VisitLink()
    {
        // Change the color of the link text by setting LinkVisited 
        // to true.
        scienceLink.LinkVisited = true;
        //Call the Process.Start method to open the default browser 
        //with a URL:
        System.Diagnostics.Process.Start("http://www.google.com");
    }
0

Try removing the try catch block:

private void linkLabel1_Click(object sender, LinkLabelLinkClickedEventArgs e) {
    Process.Start("http://www.website.com");
    linkLabel1.LinkVisited = true;
}

If that doesn't work then switch over the event to the simple clicked event:

linkLabel1.Click += new EventHandler(linkLabel1_Click);

private void linkLabel1_Click(object sender, EventArgs e) {
    Process.Start("http://www.website.com");
    linkLabel1.LinkVisited = true;
}

It's probably going to have to be switched over to the standard click event.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.