473,325 Members | 2,828 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.

How to create a file link in RichTextBox ?

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
Nov 20 '05 #1
4 17684
* ks**********@hotmail.com (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/>
Nov 20 '05 #2
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!
Nov 20 '05 #3
* kumar kss <ks**********@hotmail.com> 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/>
Nov 20 '05 #4
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!
Nov 20 '05 #5

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

Similar topics

1
by: Andrew Chanter | last post by:
I am writing a little routine to perform the following operations from an Acces 97 mdb: 1. create a fixed width text file 2. create/establish a table type link to the text file in Access 3....
1
by: ksskumar | last post by:
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. ...
0
by: Justin Creasy | last post by:
I am having a problem with creating file links in a RichTextBox. The problem occurs when there is a space in the name of a folder in the path. So if I have string path = "C:\\My Documents";...
0
by: Anatoly Kurilin | last post by:
Hi, I can create a table in the attached file: Set tdfClient = dbsBackEnd.CreateTableDef("tblClient") and so on. But I failed to create a link to that table. What's the right code to do that? ...
2
by: shefbhoy | last post by:
Hello, Ive got a problem, i want to create a link within the flash document so that it takes me to another flash document. When clicking on the link the document should open within a flash...
1
by: Mayilsamy | last post by:
hai, hai i need some information about how to load the pdf file in richtextbox using vb.net.
2
by: Mayilsamy | last post by:
hi , I need the information about How to load the file in richtextbox control using vb.net .
1
by: kevlee | last post by:
Hi. I'm pretty new to XSL and I need some help. I know I can create a text output from XSL below... ****************************************** <?xml version="1.0" ?> <xsl:stylesheet...
1
by: BD | last post by:
This is probably fairly simple but I've looked at so much code an the last few days that my brain is fried. In the past I had an HTML page that contained a lot of code items and each item was...
1
by: Khushboo Modi | last post by:
i have searched the code to display the .doc file in RichTextBox in c#..... the code works but it shows only the text in RichTextBox not the images or shapes which are in that .doc file.... Is...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.