CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2008
    Posts
    3

    How to pass hyperlink into richtextbox

    In the following code I have an OpenFile() Function which opens a fileDialogBox, I then select my file (which will be a PDF) and return it back. My question is....When I get the filename and path, is there a way to take this path and put it into a textbox or richtextbox as a hyperlink? I want the user to be able to view the file once it has been selected and displayed on the form. But when I tried the following:
    Code:
    RichTextBox1.InsertLink("linktext", "linkurl.html")
    It said the "insertLink" was not a member of richtextbox. But i see examples of it all over the net.

    Here is the code I have so far just passing the string to the textbox and richtextbox, I just need it to be passed as a hyperlink to the file location.

    Code:
    Private Sub btnOpenFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAttachDoc.Click
    
         'declare a string to the filename
         Dim strFileNameAndPath As String = Open File()
    
         If (strFileNameAndPath = "") Then
              MsgBox("You did not select a file!")
         Else
              'Pass filename to textbox and richtextbox for testing
              tbAttachment.Text = (System.IO.Path.GetFileName(strFileNameAndPath))
              tbAttachment.Text = (System.IO.Path.GetFileName(strFileNameAndPath))
         End If
    End Sub

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to pass hyperlink into richtextbox

    this worked in vb6:
    Attached Files Attached Files
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Feb 2008
    Posts
    3

    Re: How to pass hyperlink into richtextbox

    I appreciate your willingness to help, but I was unable to open up any of the forms and vb code you sent. I mean, after all....This really is just for looks and to allow the user to double check what they have posted in a file, not really needed. If I can't find anything else on it in the next day or so, i'll probably just forget it. I was looking into LinkLabel's, but then I ran into the problem of "getting" the filepath and filename from my filedialogbox over to the click function of the label. Oh well

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to pass hyperlink into richtextbox

    I searched and this is just ONE of the solutions that I found.

    http://www.vbmonster.com/Uwe/Forum.a...-in-a-text-box
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

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

Featured