Avatar of cmerlo1
cmerlo1
 asked on

C# Insert Clickable Link into RichTextBox

    I am working on a knowledgebase application.  I'm storing images and attachments to the articles in a separate table in the database.  I would like to be able to allow the author of an article to be able to insert a clickable link into the article, which is entered and displayed in a rich text box.  When a user clicks the link, the image is retrieved from the database and is displayed.
     I've tried using the 'RichTextLinks' dll from CodeProject (http://www.codeproject.com/KB/edit/RichTextBoxLinks.aspx), but the links it inserts can't be saved.
     Is there a way to create a saveable, clickable link in a rich text box, that fires the LinkClicked event?
C#

Avatar of undefined
Last Comment
cmerlo1

8/22/2022 - Mon
kaufmed

Would it not suffice to use a regular RichTextBox with DetectUrls set to true?
kaufmed

P.S.

You can handle the LinkClicked event of the RichTextBox to actually do something when the link is clicked. For example, to open up IE at the link:
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
    System.Diagnostics.Process.Start("iexplore", e.LinkText);
}

Open in new window

cmerlo1

ASKER
Correct, but how can I insert a link that isn't a URL?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
kaufmed

but how can I insert a link that isn't a URL?
Are you referring to a relative path?

e.g.
This is a sentence with a link to a myfolder/pics/img1.png file in it.

Open in new window

cmerlo1

ASKER
No, I'm going to pull an image from the database when the link is clicked and display it.  I'm not really linking to anything, I just want something clickable, that has the identity of the image I'm going to display.
ASKER CERTIFIED SOLUTION
cmerlo1

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
cmerlo1

ASKER
The issue was that the Code Project links weren't saveable.  I figured out how to save what they were, and repopulate them.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.