Re: RichText Formatting Urls

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




Hi,

Thank for the help but I'm not sure what a Regex.Replace operation is. I
load the names and urls from a file so I might note down the char positons
of the names and do it that way.

In the mean time I created a hyperlink in Word and copied and pasted it to
Wordpad. This worked which means RTF does support named links. So I saved it
as an RTF file to have a look at the rich text tags. When I used these tags
with the .Text or .SelectedText propeties for the rich text control it
simply displayed the tags as well.

However there is a RTF property against the control which gets the current
RTF text being displayed (including tags) and you can set this property to.
When I set the .RTF property to the code the word pad created it almost
worked. It displayed the name and the url ! Which means it isn't displaying
the RTF like Wordpad or Word is.

So I'm now thinking about displaying my text with HTML in .NET 2s web
browser control inless anyone has any better bright ideas ?

Mike

"Cerebrus99" <zorg007@xxxxxxxx> wrote in message
news:uw0Q8xhNGHA.1760@xxxxxxxxxxxxxxxxxxxxxxx
Hi Michael,

IMHO, there is no other "elegant" way to do this, except through coding. I
do think that creating a custom version of the RichTextBox control may not
be a viable option just to implement this functionality, in your case.

Before the text is loaded into the RichTextBox, you might use a
Regex.Replace operation to replace all text that matches a URL format, to
be
replaced by some name for the URL. Though, if you don't know beforehand,
what URL's might be present in the text, then it might become difficult

A Regex pattern that selects all URL's in any text is :
"(?:(?:mailto\:|(?:news|(?:ht|f)tp(?:s?))\://){1}(\S+))" (It stores the
part after the :// in a backreference.)

Hope that helps,

Regards,

Cerebrus.

"Michael South" <michaelsouth@xxxxxxxxxxxx> wrote in message
news:#ZObDVWNGHA.2636@xxxxxxxxxxxxxxxxxxxxxxx

Hi,

I can display a link in the rich text control which the user can click on
which then opens explorer and takes them to that page. I need to go a
step
further and display the link as a name hiding the URL behind it but when
clicked on opens up explorer in the same way. Is there some rich text
tags/codes that I can add to my text to-do this ?

I could store all the names and Urls when I load the text into the
control
and then if the mouse is over that string then use that Url if the user
clicks on it. I just wondered if there was a more elegant way of doing a
basic html operation in rich text.

Thank for any help.

Mike






.



Relevant Pages

  • Re: Concatenated text and Lebans Rich Text Control
    ... I'm not adding a line return when I insert the RTF text. ... RTF text inserted via the SelTextRTF method, into a blank control? ... Dim strColor As String ... Microsoft's integrated rich text control is pretty much useless if you ...
    (microsoft.public.access.forms)
  • Re: Printing & Saving contents of scrollable window
    ... This is an interesting problem as there really isnt a lot of support for RTF ... the image of the RTF and display the image in your control area/outline. ... there can be either text (rich text) or an image. ... > going to need to both print and save these diagrams as an image. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: RichTextBox databinding problems
    ... let you bind to a binary property that took care of all this for you. ... > the last rtf character was truncated (see post "Re: Problem with rich text ... >>> control, but this seems to ignore databinding at all. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: component that supports both graphical and text based input
    ... I dont understand how the code works and why and how i can control where the ... image comes out in the rich text control. ... >> I have quickly looked at a rich text box, how would i go about displaying ...
    (microsoft.public.vb.general.discussion)
  • Context menu problem on RichTextBox
    ... I want to find out what control is ... currently displaying the context menu. ... 'To find out which control is displaying the context menu: ... How am I supposed to do this with a rich text box? ...
    (microsoft.public.dotnet.languages.vb)