Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. RichTextBox Coloring Problem

RichTextBox Coloring Problem

Scheduled Pinned Locked Moved C#
helpquestionworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NaNg15241
    wrote on last edited by
    #1

    Hey, this is my problem: i select the last line after i added the new text, i change the color of the line, but then all the lines before becomes the first color inserted and not the color i added them before. what's the problem and how can i fix it? this is the code where i add the text in: private void rtbAddText(String NewText, Color NewColor) { NewText += Environment.NewLine; if (NewColor == null) this.rtbConsole.Text = NewText; else { int OldLength = rtbConsole.Text.Length; this.rtbConsole.Text += NewText; this.rtbConsole.Select(OldLength, NewText.Length); this.rtbConsole.SelectionColor = NewColor; //this.Select(); //rtbConsole.Select(); } } Thanks... NaNg.

    T 1 Reply Last reply
    0
    • N NaNg15241

      Hey, this is my problem: i select the last line after i added the new text, i change the color of the line, but then all the lines before becomes the first color inserted and not the color i added them before. what's the problem and how can i fix it? this is the code where i add the text in: private void rtbAddText(String NewText, Color NewColor) { NewText += Environment.NewLine; if (NewColor == null) this.rtbConsole.Text = NewText; else { int OldLength = rtbConsole.Text.Length; this.rtbConsole.Text += NewText; this.rtbConsole.Select(OldLength, NewText.Length); this.rtbConsole.SelectionColor = NewColor; //this.Select(); //rtbConsole.Select(); } } Thanks... NaNg.

      T Offline
      T Offline
      Torsten Mauz
      wrote on last edited by
      #2

      rather than using

      this.rtbConsole.Text += NewText;

      you should use

      this.rtbConsole.AppendText(NewText);

      HTH

      N 1 Reply Last reply
      0
      • T Torsten Mauz

        rather than using

        this.rtbConsole.Text += NewText;

        you should use

        this.rtbConsole.AppendText(NewText);

        HTH

        N Offline
        N Offline
        NaNg15241
        wrote on last edited by
        #3

        Thanks.... was looking for Add() function... (at start) :P

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups