Well, that depends on the format of the file.
Text (as in, one long string) by itself doesn't have any font-related properties, it's just character data.
Now, different applications use different file formats. Take HTML for example: HTML, used to represent web pages, is just plain text, with some special tags that carry metadata about the text data itself. These tags are called markup, and the browser uses them to figure out how to print the given text.
For example, this:
HTML Code:
There is a <b>bold</b> word in this sentence.
prints as:
There is a bold word in this sentence.
Then, take the forums here: a language similar to HTML is used to markup the text here. When I simulated the HTML output above, I actually typed in this.
Code:
There is a [B]bold[/B] word in this sentence.
The Rich Text Format (RTF) uses a different notation:
Code:
{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard
There is a {\b bold} word in this sentence.\par
}
So, there has to be a way for you to:
Store the formatting data as well as the text, and
interpret the formatting data in your application, so that you can draw the text properly.
Now, depending on what you mean by text, you can set the Font property on a label, or use a RichTextBox for a more advanced scenario.
But, for a more detail help, you'll have to provide additional info. What is it exactly that you're trying to do?
I have a .txt file.I have multilined text and I want to replace some of its words with some other word.So,whenever I replace a particular word,that word should be written in the text file as bold.
As mentioned above you can not work with different font info in a plain text file. You would need to use a different file type for your output as also mentioned above.
Bookmarks