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 newbie question

richtextbox newbie question

Scheduled Pinned Locked Moved C#
helpquestion
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.
  • R Offline
    R Offline
    RIPOUX
    wrote on last edited by
    #1

    hi all ! i'm pretty newbie in the coding world and have a little problem that i cant find a solution i have 2 richtextbox. the first is to write the text and the second to see it (read only) so there is my code private void button2_Click_1(object sender, EventArgs e) { DateTime dt = DateTime.Now; string str1 = dt.ToString("H:mm:ss").PadRight(10); string str2 = richTextBox1.Text; string str3 = str1 + str2 + "\n"; richTextBox2.AppendText(str3); richTextBox1.Clear(); the real goal is simple, i want the time to be wrote at the start of every text add. Thats why i made it like that. My problem is the "\n" at the end of the string 3. If i dont put it, then the next text is wrote a the end of the first one. If i put it and the user finish is text and press enter then the click button, i have a empty line (witch i dont want it). The richtextbox2 gonna be print at the end and its a report to be showed to the boss as a clean copy so empty lines need to be removed. if someone can help me btw, sorry for my english, i know i'm bad but what can i say ? i'm talking in english like in coding :laugh: thanks ;)

    L 1 Reply Last reply
    0
    • R RIPOUX

      hi all ! i'm pretty newbie in the coding world and have a little problem that i cant find a solution i have 2 richtextbox. the first is to write the text and the second to see it (read only) so there is my code private void button2_Click_1(object sender, EventArgs e) { DateTime dt = DateTime.Now; string str1 = dt.ToString("H:mm:ss").PadRight(10); string str2 = richTextBox1.Text; string str3 = str1 + str2 + "\n"; richTextBox2.AppendText(str3); richTextBox1.Clear(); the real goal is simple, i want the time to be wrote at the start of every text add. Thats why i made it like that. My problem is the "\n" at the end of the string 3. If i dont put it, then the next text is wrote a the end of the first one. If i put it and the user finish is text and press enter then the click button, i have a empty line (witch i dont want it). The richtextbox2 gonna be print at the end and its a report to be showed to the boss as a clean copy so empty lines need to be removed. if someone can help me btw, sorry for my english, i know i'm bad but what can i say ? i'm talking in english like in coding :laugh: thanks ;)

      L Offline
      L Offline
      Latheesan
      wrote on last edited by
      #2

      Um, have you tried this? DateTime dt = DateTime.Now; this.richTextBox1.SelectedText = dt.ToString("H:mm:ss").PadRight(10);

      R 1 Reply Last reply
      0
      • L Latheesan

        Um, have you tried this? DateTime dt = DateTime.Now; this.richTextBox1.SelectedText = dt.ToString("H:mm:ss").PadRight(10);

        R Offline
        R Offline
        RIPOUX
        wrote on last edited by
        #3

        i just tried but it give me the time after the text i'm still working on it thanks for the answer though :)

        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