PC Review


Reply
Thread Tools Rate Thread

How to create a file link in RichTextBox ?

 
 
ksskumar
Guest
Posts: n/a
 
      25th Feb 2004
Hi Friends,

I am creating a application using C#. In that application I am using
RichTextBox (System.Windows.Forms.RichTextBox).

My query is how to create a file link in Rich text box. Means, I want
to embed file in Richtextbox. If the user click / doubleclick /
Ctrl+click the link, that file should open. It is like hyperlink in
HTML.

The suggestion can be in C# or VB.NET.

Thanks in advance,

Kumar
 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      25th Feb 2004
* (E-Mail Removed) (ksskumar) scripsit:
> I am creating a application using C#. In that application I am using
> RichTextBox (System.Windows.Forms.RichTextBox).
>
> My query is how to create a file link in Rich text box. Means, I want
> to embed file in Richtextbox. If the user click / doubleclick /
> Ctrl+click the link, that file should open. It is like hyperlink in
> HTML.


Did you have a look at the RTF specification?

<http://msdn.microsoft.com/library/en-us/dnrtfspec/html/rtfspec.asp>

SCNR

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
 
Reply With Quote
 
kumar kss
Guest
Posts: n/a
 
      25th Feb 2004
Hi Champika Nirosh ,

Thanks for your valid suggestion. It is working fine with your idea.

But, I have one more doubt, I gave the commend to create the link like
this,

rtbTest.Text = @"file:/c:\Test.mdb";

in the output along with the file name "file:/" also display as a link.
So I have to remove it before use the LinkText to the process.

Is there any way to display the file name alone as a link?

Thanks in advance,

Kumar

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      25th Feb 2004
* kumar kss <(E-Mail Removed)> scripsit:
> Thanks for your valid suggestion. It is working fine with your idea.
>
> But, I have one more doubt, I gave the commend to create the link like
> this,
>
> rtbTest.Text = @"file:/c:\Test.mdb";
>
> in the output along with the file name "file:/" also display as a link.
> So I have to remove it before use the LinkText to the process.
>
> Is there any way to display the file name alone as a link?


Add a LinkLabel control to your form, then add this code:

\\\
Me.LinkLabel1.Text = "Besuchen Sie mich in Berlin oder Hamburg!"
Me.LinkLabel1.Links.Add(21, 6, "http://www.berlin.de")
Me.LinkLabel1.Links.Add(33, 7, "http://www.hamburg.de")
..
..
..
Private Sub LinkLabel1_LinkClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Process.Start(e.Link.LinkData)
End Sub
///

You can try to get the filename using 'System.IO.Path.GetFileName'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
 
Reply With Quote
 
kumar kss
Guest
Posts: n/a
 
      26th Feb 2004
Hi Herfried K. Wagner,

Thank you very much for the suggestion.

But, I am working in RTB (RichTextBox) not in LinkLabel. I want to
create a link in RichTextBox. That too part of the text.

My code fragment is something like this,

rtbTest.Text = "Click this link to open file " + @"file:/c:\Test.mdb";

output gives the link. but as I told above, along with the file name
"file:/" is also shown in the link.

If any possibility to avoid this ?

Herfried, still you have doubt, please let me know.

Thanks in advance,
Kumar

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot create link for object word doc. Link to file greyed out Crazyhorse Microsoft Outlook Calendar 0 9th Dec 2009 03:32 PM
RichTextBox file link Justin Creasy Microsoft C# .NET 0 27th Nov 2005 03:43 AM
Drag and drop to create a link to a file in a cell of an Excel file paulaugust2003@yahoo.com Microsoft Excel Discussion 2 18th Sep 2005 03:44 PM
How to create a file link in RichTextBox ? ksskumar Microsoft C# .NET 1 25th Feb 2004 10:43 AM
How to create a file link in RichTextBox ? ksskumar Microsoft Dot NET 0 25th Feb 2004 09:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:16 PM.