Solved

Richtextbox: Hyperlink embedded in text problem

Posted on 2010-11-16
15
1,137 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

732 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