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. how to add new line to text box

how to add new line to text box

Scheduled Pinned Locked Moved C#
tutorial
6 Posts 5 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
    prasadbuddhika
    wrote on last edited by
    #1

    i want to add a new line to a text box.

    txtstate.multiline = true

    txtstate.text+= "\n";

    or

    txtstate.appendtext("\n");

    doesn't work. all he texts are displayed in the same line.

    J A D F 4 Replies Last reply
    0
    • P prasadbuddhika

      i want to add a new line to a text box.

      txtstate.multiline = true

      txtstate.text+= "\n";

      or

      txtstate.appendtext("\n");

      doesn't work. all he texts are displayed in the same line.

      A Offline
      A Offline
      Ajay k_Singh
      wrote on last edited by
      #2

      Use – "\r\n" This should give you a new line. -Dave.

      ------------------------------------ http://www.componentone.com ------------------------------------

      1 Reply Last reply
      0
      • P prasadbuddhika

        i want to add a new line to a text box.

        txtstate.multiline = true

        txtstate.text+= "\n";

        or

        txtstate.appendtext("\n");

        doesn't work. all he texts are displayed in the same line.

        J Offline
        J Offline
        Jan Sommer
        wrote on last edited by
        #3

        you need to use \r\n (carriage return and newline)

        J 1 Reply Last reply
        0
        • J Jan Sommer

          you need to use \r\n (carriage return and newline)

          J Offline
          J Offline
          Jan Sommer
          wrote on last edited by
          #4

          damnit, too late!

          1 Reply Last reply
          0
          • P prasadbuddhika

            i want to add a new line to a text box.

            txtstate.multiline = true

            txtstate.text+= "\n";

            or

            txtstate.appendtext("\n");

            doesn't work. all he texts are displayed in the same line.

            D Offline
            D Offline
            DaveyM69
            wrote on last edited by
            #5

            Environment.NewLine

            Dave
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
            Expect everything to be hard and then enjoy the things that come easy. (code-frog)

            1 Reply Last reply
            0
            • P prasadbuddhika

              i want to add a new line to a text box.

              txtstate.multiline = true

              txtstate.text+= "\n";

              or

              txtstate.appendtext("\n");

              doesn't work. all he texts are displayed in the same line.

              F Offline
              F Offline
              FlytotheBluesky
              wrote on last edited by
              #6

              I searched and found out that in VC++ 2008 can use this

                textBox1.Text = "Line One";
              
                textBox1.Text += **Environment::NewLine**;
              
                textBox1.Text += "Line Two";
              

              Hope it help you! :)

              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