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 Problem

RichtextBox Problem

Scheduled Pinned Locked Moved C#
questiondatabasejsonhelptutorial
2 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.
  • S Offline
    S Offline
    snouto
    wrote on last edited by
    #1

    how are you Dudes ? I have one probelm in my application i need to display multiple lines in richtextbox but each line has its own attributes of new font , size and new color how can i manage this in the richtextbox knowing that i succeeded to do that using the following code but there was a small probelm . int index = richtextbox1.Find(string message , 0 , message.length); richtextbox1.select(index , 0 , message.length); richtextbox1.selectionFont = new font(font attributes goes here of the new font); richtextbox1.selectionColor = Color.Blue // for example But with the above code it will certainly manage every new written line with its new font and color attributes but if i entered two or more sentences similar to each other the first one of them will be only changed and the newly entered message which is similar to the previous will have the defaul color and font. So the question is : How can i inset multiple lines of texts each of which with different font and color attributes. Miss With The Best And Die Like The Rest

    P 1 Reply Last reply
    0
    • S snouto

      how are you Dudes ? I have one probelm in my application i need to display multiple lines in richtextbox but each line has its own attributes of new font , size and new color how can i manage this in the richtextbox knowing that i succeeded to do that using the following code but there was a small probelm . int index = richtextbox1.Find(string message , 0 , message.length); richtextbox1.select(index , 0 , message.length); richtextbox1.selectionFont = new font(font attributes goes here of the new font); richtextbox1.selectionColor = Color.Blue // for example But with the above code it will certainly manage every new written line with its new font and color attributes but if i entered two or more sentences similar to each other the first one of them will be only changed and the newly entered message which is similar to the previous will have the defaul color and font. So the question is : How can i inset multiple lines of texts each of which with different font and color attributes. Miss With The Best And Die Like The Rest

      P Offline
      P Offline
      philip_cole
      wrote on last edited by
      #2

      Hi Ive not really used richtextboxes, but looking at your code, i think you just need to change the start position in richtextbox1.Find, and then use a loop: int pos = 0; while(pos < richtextbox1.TextLength) { // search for text at last position and stop if none found int index = richtextbox1.Find(message, pos, RichTextBoxFinds.None); if(index == -1) break; richtextbox1.Select(index, message.Length); richtextbox1.SelectionFont = new Font(...); richtextbox1.SelectionColor = Color.Blue; // move to end of found text pos = index + message.Length; } Hope this helps Philip Cole

      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