Link to home
Start Free TrialLog in
Avatar of gbarcalow
gbarcalow

asked on

How to add a tooltip to an extended richtextbox link

I was wondering if there was a way to add tooltip text to a link located in a richtextboxex.

Thanks
Geoff
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Is this a link text inside of a richtextbox?\
or can you use a LinkLabel control?
Avatar of gbarcalow
gbarcalow

ASKER

No I need a tooltip for the link text inside the richtextbox
This is close as I can get

   Private Sub RichTextBox1_LinkClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.LinkClickedEventArgs) Handles RichTextBox1.LinkClicked
        tipView.SetToolTip(Me.RichTextBox1, "Here to link")
        e.GetType()
    End Sub
I have to following code
my problem is that "txtData.GetCharIndexFromPosition" is not returning the expected values.
To me it seems to choose a random integer for each line that you move over.
I think that if I could get the real index from txtData.GetCharIndexFromPosition this code would work.

    Private Sub txtData_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles txtData.MouseMove

        Dim pt As Point = New Point(e.Y, e.Y)
        Dim link As Integer = txtData.GetCharIndexFromPosition(pt)

        If isLink(link) = True Then
            tt_txtData.Active = True
            tt_txtData.SetToolTip(txtData, "Click Here to open document")
        Else
            tt_txtData.Active = False
        End If

    End Sub

    Private Function isLink(ByVal i As Integer)
        Dim sData As String = txtData.Text

        Dim strBeg As String = Replace(Strings.Left(sData, i), vbCrLf, " ")
        Dim strEnd As String = Replace(Strings.Right(sData, Len(sData) - i), vbCrLf, " ")

        Dim strComplete = Strings.Right(strBeg, Len(strBeg) - InStrRev(strBeg, " "))
        strComplete += Strings.Left(strEnd, InStr(strEnd, " "))

        If UCase(Strings.Left(strComplete, 7)) = "HTTP://" Or _
            UCase(Strings.Left(strComplete, 7)) = "FILE://" Then

            Return True
        Else
            Return False
        End If

    End Function
ASKER CERTIFIED SOLUTION
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So that pretty much rules out using word wrap huh?