Solved

Richtextbox: Hyperlink embedded in text problem

Posted on 2010-11-16
15
1,101 Views
Last Modified: 2012-05-10
Hello,
I have a problem with a richtextbox control (programming environment: VB.NET + VS2500).
Here is the scenario:
I have 2 different applications, each containing a winform with a richtextbox control.
In one application if I copy some text that contains an embedded hyperlink from - let's say - a web page, when I paste such text in the richtextbox the hyperlink will remain embedded in the text (just like in the original web page).
In the other application if I paste the same text (copied from the web page) the hyperlink is no longer embedded in the text. Instead it appears next to the text, like in this example: my_text_with_embeeded_link<http://www.mysite.com>

Both RTF controls have the exact same settings (properties), so I really don't understand what's going on here.
Please help.
Thank you,
Mac
0
Comment
Question by:macarone
  • 6
  • 4
  • 3
  • +1
15 Comments
 
LVL 5

Expert Comment

by:srinivasbn
ID: 34155395
Hi Please check the property DetectUrls. If this is true then it will automatically finds the urls in the text.


Srinivas.
0
 

Author Comment

by:macarone
ID: 34160498
Hi Srinivas,

the DetectUrls = True for both RTF controls.
The problem is not recognizing URLs but being able to "embed" a given URL in a word/sentence.

Any other ideas?
Thank you
0
 
LVL 3

Expert Comment

by:manlimnag
ID: 34163152
I think what you are saying is that it needs to understand the html like Mylink will be caption and href will be some http url. In that case I suppose you need to use html editor typr control rathr than richtextbox or control which understands the html atgs.
0
 

Author Comment

by:macarone
ID: 34163694
manlimnag:

I would agree with you on that, but - as I mentioned - in one application (a COM addin for Microsoft Office) the "html like" link works fine. However it does not work in the other app (a standalone .NET application).

How is it possible that it works just fine in one app and not in the other one?
That is the question.
0
 
LVL 3

Expert Comment

by:manlimnag
ID: 34164018
I am not sure but it may be feature of MS Office and not a feature of .Net
0
 
LVL 3

Expert Comment

by:manlimnag
ID: 34164026
More clarification Is it renedering properly and navigtion is not working or renderring is the problem?
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34164138
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:macarone
ID: 34164444
Imagine you have a word document or an HTML page with a word (or a sentence) that contains an hyperlink. For example the word "my site" that contains an hyperlink like "http://www.mysite.com"....you don't see the hyperlink but if you move your mouse over the "my site" text you see that you can click on it and follow its "embedded" hyperlink.

Imagine now that you select and copy the "my site" text and paste it an RTF box embedded in two different applications.
Now, in one case (the COM addin) the RTF control will display what you just pasted as it appears in the word document (or web page), meaning you see only the "my site" text, but if you move your mouse on it you can see there is an hyperlink behind it.
In the other case instead, you'll see the text "my site" and, next to it, the hyperlink between these two symboles <>. Ultimately it would look like this:   "mysite<http://www.mysite.com>"

I just don't understand why in one case the RTF behaves like word (or browser) while in the second case it splits the hyperlink from its text....clearly, if you configure detectURLs=true then the RTF box will "activate" the hyperlink <http://www.mysite.com>.

The question is: why is this happening and how can I have the RTF box to behave properly in both cases (= the hyperlink is hidden behind the text like in word or browser).

Hope this can help.
Mac





0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34164491
Its the hosting environment that's causing this rather than RTF itself. May the difference is in copy and paster operation when it happens within word and when it happens from word to outside world.
0
 
LVL 5

Expert Comment

by:srinivasbn
ID: 34164666
Hi Mac,

Are you sure you are using both RTF components. What i understood with your description you might add the CustomControl (COM addin) which may have the feature of copying the entire text just like in word. But the .net RTF can't copy the hidden text.

Please verify once your components.


Srinvias.
0
 

Author Comment

by:macarone
ID: 34169376
Maybe CodeCruiser you are right. But I would not pinpoint the copy-paste operation.
Instead, is it possible that the RTF control behaves differently within a VB.NET COM Addin for MS Office vs. a regular standalone VB.NET application?

I made another test with same results. Let me explain:

1) go to the COM Addin application where the RTF control displays the hyperlinks correctly (see my previous comments)

2) copy/paste some text with an embedded hyperlink and make sure the RTF control displays the hyperlink correctly (=embedded in text)

3) memorize in a string the .rtf content of the RTF control using:
Dim myRTFcontrol_content As String = My_RTF_Control.rtf

4) save and load the same .rtf in the RTF control used in the other application (making sure that the .rtf text loaded is EXACTLY the same in both cases).

RESULT: the RTF control in the second application (.NET standalone application) shows the same error, therefore displaying the same .rtf in a different way.
Pretty weird! unless the same .NET RTF control in two different environments behaves in two different ways. If so, any suggestion on how to prevent this ?

Thank you.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34171379
Hmm. That's weired. Is using the HTML control an option?
0
 

Author Comment

by:macarone
ID: 34171740
CodeCruiser:
I agree, it's very weird...the same control loading the same .rtf string will display it in two different ways (A) in a COM addin for MS Office  vs. (B) a standard standalone .exe application (both created with the same VB.NET technology)!
Unfortunately using the HTML control is not an option at this point although I recognize it is a valid alternative in other scenarios different from mine.
Any other ideas?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34171773
Cant think of any other way to be honest.
0
 

Author Closing Comment

by:macarone
ID: 34171840
does not solve the problem but provides a good alternative approach to prevent the problem from happening in the first place.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now