user2085275
user2085275

Reputation: 225

How to put a hyperlink in a label, during coding mode?

I am creating a BMI calculator, and I am wondering how to let a user click on a hyperlink when a text coded to show in a label. This is what I have so far.:

else if (bmi >= 35 && bmi <= 40)
{
     bodytypetextLabel.Text = "Visit this website. http://www.sears.com/fitness-sports-treadmills/c-1020252";
}

I'm not sure what to put in front of the "" Hyperlink so that it is made available as a hyperlink in run form for a user to click if he runs into that BMI result. Please help. Thank you in advanced.

Upvotes: 0

Views: 37892

Answers (4)

Anouar khaldi
Anouar khaldi

Reputation: 782

it's very easy :

1. you need to add :

    using System.Diagnostics;

2. it's that :

    private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
        Process.Start("https://www.google.com");
    }

Upvotes: 1

n00b
n00b

Reputation: 911

You can just use an "a" tag, an "a" tag without a URL is just like a label. Hope this helps someone.

Upvotes: 0

shashwat
shashwat

Reputation: 8004

Try this code:

bodytypetextLabel.Text = "Visit this website <a href=\"http://www.sears.com/fitness-sports-treadmills/c-1020252\">here</a>";

Upvotes: 4

Faaiz Khan
Faaiz Khan

Reputation: 332

use a link label instead of regular label to enable the hyperlink functionality.

You can visit here for more information.

Upvotes: 0

Related Questions