Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7861277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:38:55+00:00 2026-06-02T22:38:55+00:00

I want to replace a regular link with a hyperlink in my RichTextBox, all

  • 0

I want to replace a regular link with a hyperlink in my RichTextBox, all of the information is given to me via a outside library (LinkEntity). But I don’t know how to actually go about replacing the text.

I have this, but it does not work right, sometimes it throws a value cannot be null exception, and sometimes it just replaces the wrong part of the link.

        Dim Start As TextPointer = TweetText.Document.ContentStart
        Dim StartPos As TextPointer = Start.GetPositionAtOffset(LinkEntity.StartIndex)
        Dim EndPos As TextPointer = Start.GetPositionAtOffset(LinkEntity.EndIndex)
        Dim h As New Hyperlink(StartPos, EndPos)
        AddHandler h.MouseLeftButtonDown, AddressOf Hyperclick_Link
        h.NavigateUri = New Uri(LinkEntity.Url)
        h.Cursor = Cursors.Hand

The exception throws because StartPos and EndPos are nothing, even though the Start and End index have a valid value.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:38:59+00:00Added an answer on June 2, 2026 at 10:38 pm

    I found the problem, TweetText.Document did not have a value when I was calling it when declaring the StartPos and EndPos. My Final code looks like:

    Dim FlowDocument As New FlowDocument
    Dim Paragraph As New Paragraph
    Paragraph.Inlines.Add(myfireactions.FormatTweet(Tweet))
    FlowDocument.Blocks.Add(Paragraph)
    
    Dim Start As TextPointer = FlowDocument.ContentStart
    Dim StartPos As TextPointer = Start.GetPositionAtOffset(LinkEntity.StartIndex + 2)
    Dim EndIndexInt As Integer = LinkEntity.StartIndex + LinkEntity.DisplayUrl.Length + 2
    Dim EndPos As TextPointer = Start.GetPositionAtOffset(EndIndexInt, LogicalDirection.Backward)
    Dim h As New Hyperlink(StartPos, EndPos)
    AddHandler h.MouseLeftButtonDown, AddressOf Hyperclick_Link
    h.NavigateUri = New Uri(LinkEntity.Url)
    h.Cursor = Cursors.Hand
    
    TweetText.Document = FlowDocument
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want the best regular expression to replace this code <a href=http:// www.badoobook.com/clips/index.php?page=videos&section=view&vid_id=100162> www.badoobook.com/clips/inde......&vid_id=100162
I want to replace all the occurrences of a dot( . ) in a
I want to replace all mailto: links in html with plain emails. In: text
A particular regular expression is bugging me right now. I simply want to replace
Possible Duplicate: php regular expression help? hi, i want to replace i like apple
I want to replace a link with its innerHTML, how is it done? Example:
I'm trying to get a regular expression to replace all the links out of
I want to replace &lt; with < and &gt; with > using regular expression
I have a problem with Regular Expressions. I want to replace $[.....] to ${.....}.
I want to replace all double tokens in string with the double value appended

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.