RichTextBox saving different file format problem
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
6 posts
Page 1 of 1
Hello (again) CodeNStuff ,
I'll gonna give my problem directly, so here it is :
Whenever I open File that are made in RichTextBox it always added character that are irrelevant
What My Files look likes when I open it Rollover to view spoiler
What I really want.
Rollover to view spoiler
.
Is there any solution for this thing ?
I'll gonna give my problem directly, so here it is :
Whenever I open File that are made in RichTextBox it always added character that are irrelevant
What My Files look likes when I open it Rollover to view spoiler
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs17 Note Editor\par
\par
[Welcome to a new World]\par
\par
}
What I really want.
Rollover to view spoiler
Note Editor
[Welcome to a new World]
Is there any solution for this thing ?
Hey,
You first need to understand the Rich Text Format; it stores the text in it's formatted way, i.e. how it looked (color, font, etc.).
Rich Text Box can parse the .rtf format saved by WordPad on Windows and TextEdit on a Mac.
It looks different from a normal text file as it stores the formatting of the test. You can parse and show it as a file in a richly formatted way.

+Rep if it helps ;)
Cheers! (PM me if you need more help in VB/C# or any other language)
You first need to understand the Rich Text Format; it stores the text in it's formatted way, i.e. how it looked (color, font, etc.).
Rich Text Box can parse the .rtf format saved by WordPad on Windows and TextEdit on a Mac.
It looks different from a normal text file as it stores the formatting of the test. You can parse and show it as a file in a richly formatted way.
Code: Select all
That was a simple approach, if I would've been in your place, I would've written a new Class Parser and a Writer for the the file format and then would've displayed it in the text box 'Use this
Dim s As String = richTextBox1.Text
Using writer As new StreamWriter("C:\Path\to\file.txt")
writer.WriterLine(s)
writer.Close()
End Using
'That was to save the file normally (without the formatting, like the way you wanted). Load it and display it back.

+Rep if it helps ;)
Cheers! (PM me if you need more help in VB/C# or any other language)
Ok .. So only .rtf and .txt file Richtextbox can be handle ?
Then how can I save my file in different format using RichTextBox ?
Then how can I save my file in different format using RichTextBox ?
.rtf - Formatting
.txt - Without formatting!
RichTextBox can show whatever you want! Its a text box after all. Any UTF-8/ANSI text is readable in a RichTextBox.
You can save it to virtually any file (format) but you'll loose the formatting. If you want the formatting, use .rtf else use .txt.
.txt - Without formatting!
RichTextBox can show whatever you want! Its a text box after all. Any UTF-8/ANSI text is readable in a RichTextBox.
You can save it to virtually any file (format) but you'll loose the formatting. If you want the formatting, use .rtf else use .txt.
Ok . So can you suggest other than RichTextBox ?
I want to save my files in my own extension. And Read it as what should it be.
I want to save my files in my own extension. And Read it as what should it be.
You can make one by inheriting RichTextBox of System.Windows.Controls
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023