Results 1 to 5 of 5

Thread: [RESOLVED] Rich text box and URL's.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2015
    Location
    SoCal.
    Posts
    16

    Resolved [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.

  2. #2
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2015
    Location
    SoCal.
    Posts
    16

    Re: Rich text box and URL's.

    Quote Originally Posted by IanRyder View Post
    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.

    Name:  PPJzoTG.jpg
Views: 2426
Size:  61.7 KB

    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

  4. #4
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    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:
    1. Private Sub RichTextBox1_LinkClicked(sender As Object, e As LinkClickedEventArgs) Handles RichTextBox1.LinkClicked
    2.   System.Diagnostics.Process.Start(e.LinkText)
    3. 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

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2015
    Location
    SoCal.
    Posts
    16

    Re: Rich text box and URL's.

    Quote Originally Posted by IanRyder View Post
    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:
    1. Private Sub RichTextBox1_LinkClicked(sender As Object, e As LinkClickedEventArgs) Handles RichTextBox1.LinkClicked
    2.   System.Diagnostics.Process.Start(e.LinkText)
    3. 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
  •  



Click Here to Expand Forum to Full Width