473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Web link in a windows form

I have a windows form created in C#, there is web link inside it. I
would like the default browser being launched if the link is clicked on.

Does anyone know the easiest way to do so?

Thanks

Charles Zhang
Jun 14 '07 #1
4 11425
If using .net 2.0, you can just add a LinkLabel... If not, you can try
to use Reflector to copy al the control and compile it with .net 1.1
Bye

Jun 14 '07 #2
Hi Charles,

As Diego has suggested, in winform application you can use the "LinkLabel"
control to display a html hyperlink like element on form. However, you need
to hook its "LinkClicked" event and use code to programmatically launch the
default browser on the system. A very simple approach is using the
"System.Diagnostics.Process" class's "Start" method to open the target http
url. e.g.

=============
private void linkLabel1_LinkClicked(object sender,
LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://www.asp.net");
}
=============

You can also manually get the default browser image path from the following
registry:

HKEY_CLASSES_ROOT\htmlfile\shell\open\command

and use Process class to execute that program with the http url as
parameter.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 14 '07 #3
Thank you very much for the timely response.

I used LinkLable to do the trick, it worked perfectly.

Charles Zhang
Steven Cheng[MSFT] wrote:
Hi Charles,

As Diego has suggested, in winform application you can use the "LinkLabel"
control to display a html hyperlink like element on form. However, you need
to hook its "LinkClicked" event and use code to programmatically launch the
default browser on the system. A very simple approach is using the
"System.Diagnostics.Process" class's "Start" method to open the target http
url. e.g.

=============
private void linkLabel1_LinkClicked(object sender,
LinkLabelLinkClickedEventArgs e)
{
Process.Start("http://www.asp.net");
}
=============

You can also manually get the default browser image path from the following
registry:

HKEY_CLASSES_ROOT\htmlfile\shell\open\command

and use Process class to execute that program with the http url as
parameter.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 14 '07 #4
You're welcome:)

Have a nice day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Jun 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve Bezner | last post by:
I have an issue in which a link label on a windows form does not draw the focus rectangle if you programmatically force it to have focus via the Control.Focus() method. To duplicate, create a...
0
by: Steve Bezner | last post by:
I have an issue in which a link label on a windows form does not draw the focus rectangle if you programmatically force it to have focus via the Control.Focus() method. To duplicate, create...
4
by: Mike Woinoski | last post by:
(I'm new to VS, so please forgive me if this is a faq.) I'm writing some Java web services and need to test them with C++ clients. I can use either a Windows Form application or an MFC application....
1
by: Grumpy Aero Guy | last post by:
I have a VB.Net solution, for which I have created a deployment project. Everything is going good. I find this all pretty slick, by-the-way...... One innocent question. I have added a users...
1
by: VanZandt | last post by:
I have a class(dll) that extends winform datagrid to provide link column in vb.net. I have managed to create a datagrid in c# winforms that shows link in one of the column but when I try to create a...
8
by: MoshiachNow | last post by:
HI, I try to open a link using %windir% in path: <LI><A HREF="%windir%/temp/MainSetupLog.log">F </A></LI> The browser does not seem to find the file. However,If I paste in the Address window:...
38
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
3
by: Mark Ivey | last post by:
VS.Net 2002 - Visual Basic I am pretty new to VB in general, and I am having a bit of difficulty finding the right method or property to link a textbox to a filelistbox. Here is the...
5
by: aagarwal8 | last post by:
Hi, I have a windows applicationm which can open seversal forms from a main form. All the forms that are opened, from main form (as well the main form) have a link to the help (.chm) file. I...
10
by: pt36 | last post by:
Hi I have a page with a form and a textbox. before to submit the form I want to chek if the inserted value in the textbox is already present in a database. So I need to pass the textbox value...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.