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. textBox add text without deleting previous contents

textBox add text without deleting previous contents

Scheduled Pinned Locked Moved C#
question
5 Posts 4 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.
  • P Offline
    P Offline
    Pyro Joe
    wrote on last edited by
    #1

    yeah, how do I add text to a textBox (programmatically, not via the user) on the next line if there is already text in it? danke schon, Stephen

    C M 2 Replies Last reply
    0
    • P Pyro Joe

      yeah, how do I add text to a textBox (programmatically, not via the user) on the next line if there is already text in it? danke schon, Stephen

      C Offline
      C Offline
      Christian Pedersen
      wrote on last edited by
      #2

      textBox.Text += "\r\n" + newTextToAdd;

      1 Reply Last reply
      0
      • P Pyro Joe

        yeah, how do I add text to a textBox (programmatically, not via the user) on the next line if there is already text in it? danke schon, Stephen

        M Offline
        M Offline
        Member 96
        wrote on last edited by
        #3

        Also if you want to insert text at the current active point in the edit control you can programatically copy text to the clipboard then paste it in to the control by calling the controls' paste method. (it's the only way to insert text into the current position or replace highlighted text as far as i know) If you just want to append it then it's a simple: control.text+="some new text";

        M 1 Reply Last reply
        0
        • M Member 96

          Also if you want to insert text at the current active point in the edit control you can programatically copy text to the clipboard then paste it in to the control by calling the controls' paste method. (it's the only way to insert text into the current position or replace highlighted text as far as i know) If you just want to append it then it's a simple: control.text+="some new text";

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          Sorry to correct you, but TextBox has a SelectedText property, that, when set, just does what you describe: replace the text currently selected. If there's no text selected, setting SelectedText will insert this text at the cursor position. :-> mav

          M 1 Reply Last reply
          0
          • M mav northwind

            Sorry to correct you, but TextBox has a SelectedText property, that, when set, just does what you describe: replace the text currently selected. If there's no text selected, setting SelectedText will insert this text at the cursor position. :-> mav

            M Offline
            M Offline
            Member 96
            wrote on last edited by
            #5

            Nice! Thank you for pointing that out. Cheers!

            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