Thread: Text Editor Colours

  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
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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,401
    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
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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, 06:47 AM
  2. Replies: 8
    Last Post: 05-05-2010, 02:43 PM
  3. RichEditCtrl & unicode formatted text
    By ddonate in forum Windows Programming
    Replies: 0
    Last Post: 03-26-2010, 10: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, 05:45 PM