Text Editor Colours

This is a discussion on Text Editor Colours within the C# Programming forums, part of the General Programming Boards category; Hey everybody, I have a simple text Editor.NET in C#. How can I make certain words be coloured, for an ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    22

    Text Editor Colours

    Hey everybody, I have a simple text Editor.NET in C#.

    How can I make certain words be coloured, for an example text editors for programming a certain language will colour words such as "while" and "if".

    My problem is that I have no idea of where to start.


    Thanks in ADVANCE,

    David

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,597
    Create your own RTF control or use the existing one. I'm not sure the existing one actually supports text colors but you could derive your own custom control from the base to get a good start.

  3. #3
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    The existing one does support text coloring, but you have to understand the RTF format.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,597
    Nice. The RichEdit control is one I haven't used much but probably will be using when I support scripting in my 'game' editor. So you could do syntax highlighting in that control? I guess if it supports RTF then it could do that.

    I believe the OP's question has been answered then.

  5. #5
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    It does support. This is kind of a common question and they should really have provided an easier way. I believe the way you do it is by selecting a text and changing the selected text's highlight color but it can get tricky to actually make it stay a certain color.

    They are examples if you google it. I use to have some code, but I migrated it to WPF so only have for that RichTextBox.

  6. #6
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    Download details: Word 2007: Rich Text Format (RTF) Specification, version 1.9.1

    It's a bit long winded (270 pages) but covers all aspects of RTF formatting and leaves no question unanswered.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Detect OS version
    By linucksrox in forum Windows Programming
    Replies: 4
    Last Post: 05-18-2010, 07:47 AM
  2. Replies: 8
    Last Post: 05-05-2010, 03:43 PM
  3. RichEditCtrl & unicode formatted text
    By ddonate in forum Windows Programming
    Replies: 0
    Last Post: 03-26-2010, 11:50 AM
  4. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  5. Replies: 1
    Last Post: 07-13-2002, 06:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21