问题
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.
回答1:
Try this code:
bodytypetextLabel.Text = "Visit this website <a href=\"http://www.sears.com/fitness-sports-treadmills/c-1020252\">here</a>";
回答2:
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");
}
回答3:
use a link label instead of regular label to enable the hyperlink functionality.
You can visit here for more information.
回答4:
You can just use an "a" tag, an "a" tag without a URL is just like a label. Hope this helps someone.
来源:https://stackoverflow.com/questions/15044170/how-to-put-a-hyperlink-in-a-label-during-coding-mode