Walt Ritscher: Thinking about code

Thoughts about .Net - Thoughts about code

  Home :: Contact :: Syndication  :: Login
  171 Posts :: 0 Stories :: 80 Comments :: 23 Trackbacks

Archives

Post Categories

Image Galleries

About Me

Interesting Blogs

My other blogs

Resources

It's common in web programming to place links to resources on a page.  The hyperlink tag is on nearly every page on your website.  But what about Windows Forms?

In .NET it is easy to add a hyperlink to a form.  At least it looks and acts like a hyperlink.

  1. Add a LinkLabel to the form.
  2. Change the text to the web address (example http://www.waltritscher.com/ )
  3. In the LinkClicked event add one line of code.

   

Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Process.Start(LinkLabel1.Text)

    End Sub

This works because Windows knows that a string with http:// is a web address and will launch the users default web browser.  Process.Start merely asks Windows to launch a process based on the file/URL string being passed as parameter.


posted on Saturday, June 18, 2005 6:14 PM

Feedback

# re: Adding a Working Hyperlink to Your 'Windows Form' in .NET 2/21/2006 6:05 PM Brian
I am teaching myself how to program MS Visual Basic 2005 and creating a database and wanted to place a hyperlink on it directing users to my company web site and I been reading and searching how to do this for days and finally I've come across your site and it worked. A simple 3 liner. Thanks a bunch.

# re: Adding a Working Hyperlink to Your 'Windows Form' in .NET 2/21/2006 11:55 PM Walt Ritscher
Glad it worked for you.

Comments Closed! Due to the spam creeps.
If you want to comment, use the contact page and send me an email and the URL of this Post.
Title  
Name  
Url

Comments   
Enter the code you see: