RichTextBox - Open Detect URLs

Use this board to post your code snippets - tips and tricks
5 posts Page 1 of 1
Contributors
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

RichTextBox - Open Detect URLs
CodenStuff
Hello,

A quick snip to show you how to launch a webpage from a link inside a richtextbox control. First you need to set the "DetectUrls" propertie to 'True' which will make URL text placed inside a richtextbox clickable.

Then use this code in the "RichTextBox LinkClicked" event:

To open in specific webbrowser:
Code: Select all
System.Diagnostics.Process.Start("iexplore.exe", e.LinkText)
To open in default webbrowser:
Code: Select all
System.Diagnostics.Process.Start(e.LinkText)
- credit to robby1998 for the default link

Its here just incase anyone needs it.

Happy coding cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: RichTextBox - Open Detect URLs
Nery
Can't you just use:
Code: Select all
Process.Start("e.LinkText")
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Hello Nery,

Yes you can, either way does the same job cooll; .

Thank you.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: RichTextBox - Open Detect URLs
Nery
I knew it, it's just way more simple which means you can call the same action with a smaller piece of code. ^_^
User avatar
Neki
Top Poster
Top Poster
Posts: 96
Joined: Sun Oct 11, 2009 10:12 am

Re: RichTextBox - Open Detect URLs
Neki
The both ways are simple :)
5 posts Page 1 of 1
Return to “Quick Snips”