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
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 to share
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:
0
source to share