changing format of RichTextBox without selecting any text - c#

I would like to create a Richtextbox which load a huge file (several pages of text in some format) and based on format it formats the text (let's say it display html).
I found how to change format of text using selection, but that is very slow and resource expensive. Is there a way to append a preformatted text to Rich Text Box? So that I can format each element and then append it.

This might help you if not the answer you are looking for
But RichTextBox.CanPaste Method determines whether you can paste information from the Clipboard in the specified data format. Please see link the for the System.Windows.Forms.DataFormats it will support

Related

UP simple Way to store/retrieve formatted Text

currently, I'm using Richeditbox in my to edit and display formatted text in App. there a now a lot of RichEditBoxes. because its the goal of the App, to show a list of formatted text blocks with different Content. The Performance is really slow and the space in DB is great, I'm storing the text in RTF-format in blobs.
What is the easiest way to show simple formatted Text (eg bold, italic)? I never found a quite sample?
If you just want to display formatted text you have two options.
RichTextBlock is a TextBlock-like counterpart of RichEditBox. It is however more performant as it just displays the content and does not offer editing.
Alternatively there is a MarkdownTextBlock control in the UWP Community Toolkit, which can display simple formatted text in the Markdown format.

How to display RTF text in to tinyMCE editor

I am using tinyMCE editor. I have rtf formatted string in database column which I want to show in the browser editor i.e. tinyMCE. So that, user will edit the text as he wants. But for that I found I need to convert the rtf string in to xml to see it, since my tinyMCE is showing xmls properly. I am able to show the text from rtf string but I misses out the formatting like bold text, red colored text, \n etc. I want to retain all this formatting. How shall I retain the formatting or how shall I display the rtf text with the formatting or how shall I convert rtf text in to xml properly? I want to display rtf text like I am saving it in some rtf file and opening that file in ms word or open office word that way I want to see the format. rtf is Rich Text format.
You should convert your RTF to HTML and use that for TinyMCE, here is a code project article that will get you started :
http://www.codeproject.com/Articles/27431/Writing-Your-Own-RTF-Converter

put \\scaps in RTF for small caps

I'm using dynamic RichTextBox control in C# 2.0 and I want to insert "\scaps" in RTF so that if the file is saved programatically and then opened in MS-Word certain text be seen smallcaps.
Can anyone tell me the code as how to insert the tag?
Well, you can access the rich text directly through the Rtf property on the rich text box.

change font of a string in C#

I am reading a txt file and writing it's content to another txt file.
Before writing the content to new file i have to change the font of the string (string that is read from another file).
How should i do this.
Please help.
Strings don't inherently have fonts. If the string represents RTF or something like that, then that's a different matter - it's effectively changing the font within the RTF format.
However, if you're just writing a plain text file, it's entirely up to the display client which font it uses.
Sorry!! friend. you can't change the fonts or size of string. C# don't know where your are going to write the string text... Console or any text file or label...
Just think what happens if it supports, lets u set some format to string and in place of writing to a file you are printing to console (Console is not rich in fonts)
anyway !! but if you want to do it, it depends on the type of file you are writting. notepad, or rtf orword document. There you can find changing fonts very easily.
If it is pure text file, then you cannot!
If you are writing a Word Doc, using some Office API then you can!
a simple string has no font. A font is used for printing or displaying a string, but a string itself is only text. If you are talking about some encoded text (like rtf) you are reading, you will need to parse the text into something interpretable and go on from there.
If you only want to put out one or more strings in a textbox using different fonts, you will need to use a control that supports formatting.

c# Write data to an rtf file

I am trying to write data to an RTF file and set certain characters to a different color. I found out how to do it in a box but I can't figure out how to write it to a file.
If by "do it on a box" you mean RichTextBox you can use the RichTextBox.SaveFile() mothod.
Take a look here.

Categories

Resources