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

隐身守侯 提交于 2019-12-08 03:15:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!