Adding hyperlink to win app

I am looking for a way to use hyperlinks in a winforms environment.

I found that he uses System.Web.UI.WebControls

; but when i tried to use it in my program System.Web

it was as far as it would be. So I checked refrences but also not System.Web.UI.WebControls

or something, any sugestions?

+5


source to share


4 answers


If you are developing a WinForms application, you must use an System.Windows.Forms.LinkLabel

assembly-located control System.Windows.Forms

. Controls System.Web.*

are for HTML pages.



+6


source


You can use the LinkLabel control. Set the LinkLabel text property to show your web link. You can use the LinkClicked event to open the web browser as shown below. Hope this helps you.



     private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
        System.Diagnostics.Process.Start(linkLabel1.Text);
    }

      

+7


source


Why dont you use Link Label

+5


source


If it is WPF

, you can do something like this:

<TextBlock>           
    <Hyperlink NavigateUri="http://www.google.com" RequestNavigate="Hyperlink_RequestNavigate">
        Click here
    </Hyperlink>
</TextBlock>

      

And in the code:

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
    Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
    e.Handled = true;
}

      

It will look like this:

oO

0


source







All Articles