Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2004, 05:27 PM
Authorized User
 
Join Date: Jan 2004
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Default Saving Rich Text Box Formatting

When I save a file in rich text format it seems to save fine. When I open the file however it does not have any formatting. How do I keep the formatting when saving text from a rich text box.
 
Old February 24th, 2004, 10:03 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

How are you saving the file? Are using RTF format when you save?

Also, how are you opening it? When you open it with Microsoft word does it keep your formatting?

J
 
Old February 24th, 2004, 05:07 PM
Authorized User
 
Join Date: Jan 2004
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Default

I am saving it as a .rtf file. In Word the file opens up with all the words in the font Courier New, size 10. When I open it with my program it takes the formatting of the first word.
 
Old February 24th, 2004, 09:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

OK, but are you saving it as richtext. It sounds like you are just appending an "rtf" extension, but it is still being saved in text format. For example when you saving your file are doing something like:

RichTextBox1.SaveFile("C:\MyFile.rtf", richTextBoxStreamType.RichText)

Create a file in notepad and save it, then open it in Word. I am sure you will see the same settings (font Courier New, size 10) as the file you are trying to create in your program.

Let me know if I am wrong and I will try to think of something else.

J
 
Old February 28th, 2004, 02:31 PM
Authorized User
 
Join Date: Jan 2004
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Default

The code you gave me worked, but only when I use word to open it. When I use my program it shows up as:
{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\lang1033\i\f0\fs17 Test \i0 Test \b Test\b0\i\par
}

What code do I need to use to open it correctly?
 
Old February 29th, 2004, 02:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

RichTextBox1.LoadFile("C:\MyFile.rtf", RichTextBoxStreamType.RichText)

-------------------------------------

Obviously substitute your file path and name...

J





Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting inside Rich Text Box bettiahamit .NET Framework 3.5 1 November 10th, 2008 06:04 AM
Rich Text Box aliirfan84 ASP.NET 2.0 Professional 1 February 23rd, 2007 06:35 AM
Rich Text Box spike010101 Pro VB 6 1 September 29th, 2004 02:37 AM
RICH TEXT BOX priyanka123 VB How-To 0 May 6th, 2004 01:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.