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)
        {
        }

Recommended Answers

All 2 Replies

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");
    }

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.