473,729 Members | 2,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

saving rich text box data!

Lee
Hi,

I have a rich text box that can have hyperlinks ect within the text!

when I save this data to file how should I do it? that is can I just save it
as text?

or do I need to serialize it beforehand to preserve the hyperlink info?

thanks in advance
Mar 20 '06 #1
5 8217
> when I save this data to file how should I do it? that is can I just save
it as text?

If your rich text box is called "richTextBo x1", you can load a file like
this:

this.richTextBo x1.LoadFile("C: \\Document.rtf" );

and save the content with this line:

this.richTextBo x1.SaveFile("C: \\newFile.rtf") ;

Regards,
Lars-Inge Tønnessen
Mar 20 '06 #2
Lee
sorry I wasn't very clear,

I am saving the rich text box data as part of an xml file.

thanks
"Lars-Inge Tønnessen (VJ# MVP)" <http://emailme.larsing e.com> wrote in
message news:Ok******** ******@tk2msftn gp13.phx.gbl...
when I save this data to file how should I do it? that is can I just save
it as text?

If your rich text box is called "richTextBo x1", you can load a file like
this:

this.richTextBo x1.LoadFile("C: \\Document.rtf" );

and save the content with this line:

this.richTextBo x1.SaveFile("C: \\newFile.rtf") ;

Regards,
Lars-Inge Tønnessen

Mar 20 '06 #3
You get the raw rtf from the "Rtf" method (this.richTextB ox1.Rtf).
You would have to code this rtf formatted text into characters that XML can
store. XML can not store all charaters.

Format the rtf as Base64.

this.richTextBo x1.LoadFile("C: \\Document.rtf" );
System.Text.ASC IIEncoding enc = new System.Text.ASC IIEncoding();
string StoreMe =
System.Convert. ToBase64String( enc.GetBytes(th is.richTextBox1 .Rtf));
System.Windows. Forms.MessageBo x.Show(StoreMe) ;

Regards,
Lars-Inge Tønnessen
Mar 20 '06 #4
Lee
thanks.. but!

how on earth do I read the Base64 data back into a string?

thanks
"Lars-Inge Tønnessen (VJ# MVP)" <http://emailme.larsing e.com> wrote in
message news:eL******** ******@TK2MSFTN GP14.phx.gbl...
You get the raw rtf from the "Rtf" method (this.richTextB ox1.Rtf).
You would have to code this rtf formatted text into characters that XML
can store. XML can not store all charaters.

Format the rtf as Base64.

this.richTextBo x1.LoadFile("C: \\Document.rtf" );
System.Text.ASC IIEncoding enc = new System.Text.ASC IIEncoding();
string StoreMe =
System.Convert. ToBase64String( enc.GetBytes(th is.richTextBox1 .Rtf));
System.Windows. Forms.MessageBo x.Show(StoreMe) ;

Regards,
Lars-Inge Tønnessen

Mar 21 '06 #5
> how on earth do I read the Base64 data back into a string?

Like this:

this.richTextBo x1.LoadFile("C: \\Document.rtf" );

// From RTF to Base64
System.Text.ASC IIEncoding enc = new System.Text.ASC IIEncoding();
string StoreMe =
System.Convert. ToBase64String( enc.GetBytes(th is.richTextBox1 .Rtf));
System.Windows. Forms.MessageBo x.Show(StoreMe) ;

// Back from Base64 to RTF
byte[] result = System.Convert. FromBase64Strin g(StoreMe);
string RTFString = enc.GetString(r esult);
System.Windows. Forms.MessageBo x.Show(RTFStrin g);
Regards,
Lars-Inge Tønnessen
Mar 21 '06 #6

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

Similar topics

1
7764
by: PC User | last post by:
I found this Rich Text Editor and I've been trying to recreate it in my own application. I've had trouble with the COMCTL.ImageListCtrl and the COMCTL.Toolbar to recreate the toolbar. And I've had trouble with COMCTL.SBarCtrl in recreating the status bar. Does anyone have any experience with these or know of any website that explaines how to use these? http://www.access-programmers.co.uk/forums/attachment.php?attachmentid=5545 ...
1
3412
by: Peter | last post by:
I have written a small terminal app that reads and writes to the serial port. In particular as the data is read from the serial port it is appended to the rich text box. The problem I am experiencing is this: When CrLf is received in the same read and appended to the rich text box, it processes it by moving to the beginning of the next line. This is right. When Cr is received at the end of one read it is appended to the rich text box....
8
3284
by: AxOn | last post by:
Hi, How can i save the specific RichTextBox in the selected tab if i have several tabs with RichTextBoxes in? The application is a text editor type program and when i try to save the most recently opened text file in the rich text box my application saves that file over the other files?? Can i some how index the new RichTextBoxes so that only the text in the selected RichTextBox is saved??
1
11762
by: tomi.trescak | last post by:
Hi I have a problem with storing rich text in MySQL. I store rich text in MySQL (in column with type "text") which i get from Rich Textbox control. When i do reverse processing by trying to fill rich text back to rich techbox (i set correct property "Rtf") i get whole text like: { tf1ansiansicpg1250deff0deflang1029{fonttbl{f0fnilfcharset0
5
5367
by: ARC | last post by:
Just found out something interesting with Access 2007... In table design, if you set a memo field to the new rich text option, and put that control on a form, set the control to rich text, you can only use the text formatting menus IF the control is on a parent form! If the control is placed on a form that is a subform, the mini format toolbar, and the access toolbar will not work! However, if you place the control on a self-contained...
16
11127
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might know one way or the other whether that was true or not, or could point me to an article or help text that would. What I have seen so far online and in Access 2007 help seems to confirm the above. But that (or at least (b)) seems incredible that it...
0
1400
Ajm113
by: Ajm113 | last post by:
Contributing To: Saving RichTextBox from Tab Control Ok, I have a question what would I use if I wanted to do something like a paste function in a Rich Text Box using the code on that thread? Thanks, Ajm113.
0
1190
by: Michelle Monty | last post by:
Hi, I'm trying to create a program where the user can enter check information and the information is saved to a sequential access file. I'm getting an error when I run the program. The error is "Object reference not set to an instance of an object" and I'm getting it on the line that I have the ***** in front of below. Can anyone help me figure out how to fix this error? Thanks for your help. Here's my code: Option Explicit On Option...
2
1543
by: Michelle Monty | last post by:
Hi, I'm trying to create a program where the user can enter check information and the information is saved to a sequential access file. I'm getting an error when I run the program. The error is "Object reference not set to an instance of an object" and I'm getting it on the line that I have the ***** in front of below. Can anyone help me figure out how to fix this error? Thanks for your help. Here's my code: Option Explicit On Option...
0
8913
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
8761
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,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6016
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
4525
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
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
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
2677
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.