473,770 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.RichText Box).

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 17722
* ks**********@ho tmail.com (ksskumar) scripsit:
I am creating a application using C#. In that application I am using
RichTextBox (System.Windows .Forms.RichText Box).

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**********@h otmail.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.T ext = "Besuchen Sie mich in Berlin oder Hamburg!"
Me.LinkLabel1.L inks.Add(21, 6, "http://www.berlin.de")
Me.LinkLabel1.L inks.Add(33, 7, "http://www.hamburg.de" )
..
..
..
Private Sub LinkLabel1_Link Clicked(ByVal sender As Object, ByVal e As System.Windows. Forms.LinkLabel LinkClickedEven tArgs) Handles LinkLabel1.Link Clicked
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
12257
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. allow the user to view the text contained in the text file via an Access form. I have been able to achieve this, albeit with one major limitation. That is that the name of the text file needs to be known prior to runtime. In other
1
7448
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. 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.
0
1472
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"; string fileName = "someFile.txt"; string link = "file://" + path + "\\" + fileName; The link will appear, but only up to "My" and not extending to
0
1193
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? AK
2
2108
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 player rather than a browser. All advice will be much appreciated. thank you!
1
3232
by: Mayilsamy | last post by:
hai, hai i need some information about how to load the pdf file in richtextbox using vb.net.
2
1440
by: Mayilsamy | last post by:
hi , I need the information about How to load the file in richtextbox control using vb.net .
1
1304
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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text" indent="text" /> <xsl:template match="/person"> BEGIN:VCARD
1
1430
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 contained in it's own hidden <div>. The div was displayed by extracting the bookmark, for example mypage.htm#sec2 would display the div with the id of sec2. It worked but as you can imagine it was rather clumsy as the number of items increased. At...
1
3056
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 there any way to show the images and shapes of doc file in RichTextBox plezzz let me know.... i m sending u the code along with it if there is any change in it plezzz tell.... IDataObject Data1;
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10037
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.