CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2012
    Posts
    18

    How to make some words in a text file bold?

    How to make some words bold in a given text file through the program?

  2. #2
    Join Date
    Jan 2010
    Posts
    1,133

    Re: How to make some words in a text file bold?

    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:
    1. Store the formatting data as well as the text, and
    2. 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?

  3. #3
    Join Date
    Jan 2012
    Posts
    18

    Re: How to make some words in a text file bold?

    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.

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to make some words in a text file 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.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jun 2001
    Location
    Melbourne/Aus (C# .Net 4.0)
    Posts
    686

    Re: How to make some words in a text file bold?

    Which program are you using to view your text files?

    Look at the documentation for that program and see what you need to insert into the text in order for it to display in bold.

    See the examples given previously..

    If you are viewing the file in one of the Coifs (Chrome, Opera, IE, Firefox, Safari browser) then you will need to insert..

    There is a <b>bold</b> word in this sentence.

    Usually, the extension of the file name, eg .HTM, .RTF, .DOCX determines the format of the text inside, so (unfortunately) there is not one fits all.

    etc
    Rob
    -
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured