Link to home
Create AccountLog in
Avatar of cnxmax
cnxmax

asked on

LinkClicked event for RichTextBox only works with first URL put into box

I'm working in visualstudio 2012RC with vb.net and creating a windows application.

I fill a ListView and handle its selectedindexchanged event to fill some textboxes.  One of the textboxes is a richtextbox (RichTextBoxPreviewURL, DetectURLs=true)...into which I place URL text.

I can select any item in the ListView and then click on the RichTextBoxPreviewURL text (which uses a hand/finger mouse pointer with blue, underlined text in the box.) to get the webpage displayed.  That works fine.  An IE is opened and the correct webpage is displayed.  I can repeat this many times...as long as i don't change the URL text in the RTB.

I then go to select another item in the ListView.  All textboxes are refilled and a new URL appears in the RichTextBoxPreviewURL.  I mouse over the blue, underlined text in the box (hand/finger mouse appears) and click...nothing happens.


With a little debuging  I can tell that the LinkClicked event fires when I click on the first URL text I place in the box but it does not fire ever again.  I have to restart the application to get it to fire again.

I can start this process with any item in the ListView and the correct page is displayed...but no subsequent webpage is displayed after the first one...the LC event fires only one time.

Here is the code that places text into RichTexBoxPreviewURL:

    Sub DisplayHITtypeAndOrHITinformation( ByVal sHITid As String)
        Dim oClient As New SimpleClient
        Dim oHIT As New HIT

        Try
                oHIT = oClient.GetHIT(sHITid)
                With oHIT
                    TextboxTitle.Text = .Title
                    TextboxDescription.Text = .Description
                    TextBoxReward.Text = .Reward.Amount.ToString
                    TextBoxDuration.Text = CInt(.AssignmentDurationInSeconds).ToString
                    TextBoxKeywords.Text = .Keywords
                    TextboxQuestion.Text = .Question
                    TextBoxExpiration.Text = (CDate(.Expiration) - DateTime.Now).TotalMinutes.ToString
                    TextBoxAssignments.Text = .MaxAssignments.ToString


                    RichTextBoxPreviewURL.Text = oClient.GetPreviewURL(.HITId)
                End With
            End If
        Catch ex As Exception
            oEventLogMain.WriteEntry(ex, "id=" & "*", "", EventLogEntryType.Error)
        End Try
    End Sub

Here is the LinkClicked event handler:

Private Sub RichTextBoxPreviewURL_LinkClicked(sender As Object, e As System.Windows.Forms.LinkClickedEventArgs) Handles RichTextBoxPreviewURL.LinkClicked
        Try
            System.Diagnostics.Process.Start(e.LinkText)
        Catch ex As Exception
            oEventLogMain.WriteEntry(ex, "id=" & "*", "", EventLogEntryType.Error)
        End Try
    End Sub

Any thoughts about why the LC event does not fire after refilling the RTB would be appreciated.  I gave this 500 points because I have spent hours in google over the past two days searching for assistance.  thanks.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Why would you still be using a release candidate version?
Avatar of cnxmax
cnxmax

ASKER

To: TheLearnedOn, is RC an issue or just an idle observation?
I wouldn't think that using a release candidate would be a good choice, since there is a RTM version available for 2012.  Who knows if that is a bug that was fixed in the RTM version.  RC versions are considered betas, and should not be used in a production environment.
ASKER CERTIFIED SOLUTION
Avatar of cnxmax
cnxmax

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of cnxmax

ASKER

good advise