-
May 19th, 2015, 12:01 AM
#1
Thread Starter
Junior Member
[RESOLVED] Rich text box and URL's.
Hi, I'm wondering how to click on a URL within a rich text box?
I know I can use a link label; but the program I have right now is reading text files into a rich text box, these files contain some links. I have detect URL property set to true and the cursor changes to a hand when I mouse over the URL. Although, I cannot click it. I have to copy & paste and open a web browser myself in order to see where the URL goes.
These URL's are not blue, they're not clickable which is my problem.
VB 2010 Express btw.
-
May 19th, 2015, 12:07 AM
#2
Re: Rich text box and URL's.
Hi and Welcome to the Forum,
I have not tested this but it sounds like this should do the trick:-
RichTextBox.LinkClicked Event
Hope that helps.
Cheers,
Ian
-
May 19th, 2015, 01:17 AM
#3
Thread Starter
Junior Member
Re: Rich text box and URL's.
Originally Posted by IanRyder
Hi and Welcome to the Forum,
I have not tested this but it sounds like this should do the trick:-
RichTextBox.LinkClicked Event
Hope that helps.
Cheers,
Ian
Hi, thank you for the fast response! Although, I came across that link yesterday and I still could not get it to work. Perhaps I was not implementing the code properly.
This is what I am dealing with for example.
Pic of formatted but not clickable URL's.
Sample code.
Code:
Private Sub FrmTheComicReliefStereotype_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Read from TheMagicalNegroIntro.txt file.
Dim ReadFile As String
ReadFile = My.Computer.FileSystem.ReadAllText("G:\Visual Basic Programs\African American Stereotypes\Comedic Relief\ComedicReliefIntro.txt")
RtbTheComedicRelief.Text = ReadFile
'Clear the actor list.
LstActors.Items.Clear()
'Add items to the listbox (actors).
'Add items to the listbox (actors).
LstActors.Items.Add("Chris Tucker")
LstActors.Items.Add("Tom Kenny and Reno Wilson")
'Set selected item to nothing.
LstActors.SelectedItem = Nothing
'Clear the movie list.
LstMovies.Items.Clear()
'Hide the listbox for movies.
LstMovies.Visible = False
'Hide the label for movies.
LblMovies.Visible = False
'Clear the picturebox.
PicComicRelief.Image = Nothing
End Sub
-
May 19th, 2015, 02:31 AM
#4
Re: Rich text box and URL's.
Hi,
I have just tested this myself and it works as expected so I guess you did not code this right the first time round like you mentioned.
You should have in your code a routine similar to this:-
vb.net Code:
Private Sub RichTextBox1_LinkClicked(sender As Object, e As LinkClickedEventArgs) Handles RichTextBox1.LinkClicked System.Diagnostics.Process.Start(e.LinkText) End Sub
Have you added that? If not, then Select the RichTextBox, click on Events and then Double Click on the LinkClicked Event to generate that event in your code. You can then add the Process information shown above and you are good to go.
Hope that helps.
Cheers,
Ian
-
May 19th, 2015, 03:03 AM
#5
Thread Starter
Junior Member
Re: Rich text box and URL's.
Originally Posted by IanRyder
Hi,
I have just tested this myself and it works as expected so I guess you did not code this right the first time round like you mentioned.
You should have in your code a routine similar to this:-
vb.net Code:
Private Sub RichTextBox1_LinkClicked(sender As Object, e As LinkClickedEventArgs) Handles RichTextBox1.LinkClicked
System.Diagnostics.Process.Start(e.LinkText)
End Sub
Have you added that? If not, then Select the RichTextBox, click on Events and then Double Click on the LinkClicked Event to generate that event in your code. You can then add the Process information shown above and you are good to go.
Hope that helps.
Cheers,
Ian
Cool thank you! Now all my links work!
So simple :3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|