473,325 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Using links in RichTextBox control

Hi,
I want to dynamically add links into a richtextbox control. However, I
actually don't want to go to a web page, I just want to catch the linkclick
event and do something else.

This works fine by using DetectUrls and writing links like
www.microsoft.com. But how do I do if I don't want the link to look like a
url but like an instruction (e.g Add) instead?

Do I have to use the MouseClick event, then find out on what word the user
clicked and then perform the operation or is there another way? Something
easy like link:Add would be nice if it worked :)

Thanks,

Mats-Lennart
Nov 16 '05 #1
2 8035
You could just set the color of the "links" when you fill the richtextbox:

richTextBox1.Select(startIndex, endIndex);
richTextBox1.SelectionColor = Color.Blue;

And then in your click event for the richTextBox have:

if(richTextBoxRules.SelectionColor == Color.Blue)
....

--Liam.

"Mats-Lennart Hansson" <ap********@hotmail.com> wrote in message
news:u5**************@TK2MSFTNGP09.phx.gbl...
Hi,
I want to dynamically add links into a richtextbox control. However, I
actually don't want to go to a web page, I just want to catch the linkclick event and do something else.

This works fine by using DetectUrls and writing links like
www.microsoft.com. But how do I do if I don't want the link to look like a
url but like an instruction (e.g Add) instead?

Do I have to use the MouseClick event, then find out on what word the user
clicked and then perform the operation or is there another way? Something
easy like link:Add would be nice if it worked :)

Thanks,

Mats-Lennart

Nov 16 '05 #2
Oh, thats a nice workaround. Annoying I couldn't see it myself though... :)

Thanks!

/Mats-Lennart

"Liam McNamara" <re***@newsgroup.net> wrote in message
news:K9**************@news-srv1.fmr.com...
You could just set the color of the "links" when you fill the richtextbox:

richTextBox1.Select(startIndex, endIndex);
richTextBox1.SelectionColor = Color.Blue;

And then in your click event for the richTextBox have:

if(richTextBoxRules.SelectionColor == Color.Blue)
...

--Liam.

"Mats-Lennart Hansson" <ap********@hotmail.com> wrote in message
news:u5**************@TK2MSFTNGP09.phx.gbl...
Hi,
I want to dynamically add links into a richtextbox control. However, I
actually don't want to go to a web page, I just want to catch the

linkclick
event and do something else.

This works fine by using DetectUrls and writing links like
www.microsoft.com. But how do I do if I don't want the link to look like a url but like an instruction (e.g Add) instead?

Do I have to use the MouseClick event, then find out on what word the user clicked and then perform the operation or is there another way? Something easy like link:Add would be nice if it worked :)

Thanks,

Mats-Lennart


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: vanvee | last post by:
Hi I have a user control that contains a RichTextBox in vb.net. In my program, I create multiple instances of this control (with the RichTextBox being in each one), that appear one above the...
3
by: Maya | last post by:
Hey, there! I'm new to vb.net and it seems I wouldn't be able to solve this without help. I have a pipe delimited file that has to be saved in txt format so it could be accepted by my DTS...
1
by: Nathan Carroll | last post by:
In an mdi environment I constructed a child for with a richtextbox control that is used to load .rtf's. This works fine on the intiatial load of the form but when for is closed and reopened later...
2
by: Neo Chou | last post by:
Greetings! I'm trying to make my ASPX page able to process WORD format document. I learned that RichTextBox might help me, but I can't use it either by adding it to my Web Control list or by...
1
by: Eric | last post by:
Using the 1.1 framework. We are using a newly created instance of a RichTextBox Class in our server code to manipulate RTF that is stored in the database. To clarify, we are not using or...
0
by: Artboy717 | last post by:
Hello , is there a way to create custom links to a richtextbox control? By default if you enable DetectUrls , the control shows urls as links and can be clicked. How can implement this so it shows...
1
by: tulasi | last post by:
I am placing textbox controls and combo box controls on richtext box and 2 command buttons on form control. after executing the application i'll place some text into textbox controls and select a...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
3
by: ommail | last post by:
I have two RichTextBox controls on a form, and single ContextMenuStrip control which serves for both textboxes. I need to determine which RichTextBox control invokes an event handler in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.