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. multiline programmatically formatting text

multiline programmatically formatting text

Scheduled Pinned Locked Moved C#
helptutorialquestion
5 Posts 3 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

    hi, I know how to format a paragraph programmatically, using "\r" to return to the next line in a rich text box, and continue adding text to the next line. but there are a couple problems I've run into doing this. first, I hate putting a giant paragraph on a single line, cause it makes the (i think it's called) buffer really wide, kinda like not turning on word wrap. Secondly, my main problem is, it takes a long time to insert all the + "\r" + "text "\r", etc. is there an easier way to do this? if not, someone should make a tutorial with an app. I thought about trying to do this myself, but I don't know how to use regular expressions very well, which seems the best way to go about making an app that could do this. that could automatically reveal formatting. Keep in mind, I would like to insert this text at the current cursor position. thanks for the help, Stephen

    H P 2 Replies Last reply
    0
    • P Pyro Joe

      hi, I know how to format a paragraph programmatically, using "\r" to return to the next line in a rich text box, and continue adding text to the next line. but there are a couple problems I've run into doing this. first, I hate putting a giant paragraph on a single line, cause it makes the (i think it's called) buffer really wide, kinda like not turning on word wrap. Secondly, my main problem is, it takes a long time to insert all the + "\r" + "text "\r", etc. is there an easier way to do this? if not, someone should make a tutorial with an app. I thought about trying to do this myself, but I don't know how to use regular expressions very well, which seems the best way to go about making an app that could do this. that could automatically reveal formatting. Keep in mind, I would like to insert this text at the current cursor position. thanks for the help, Stephen

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      A "buffer" is a block of memory that holds data. The text buffer (a char[] array, actually) will be even larger if you insert return codes because you'll be including 1-2 extract characters every so often. How the buffer is displayed is a user interface. If you want to insert a return code you must use the correct return code for the underlying platform. The Environment.NewLine property abstracts this detail away from you, since - on Windows - the actual new line constant is "\r\n". For console output you can use simply "\n" which gets translated appropriately, but for most text you should use Environment.NewLine. For example:

      string value = string.Format("This is a{0}broken line.{0}This is a separate line.", Environment.NewLine);
      label1.Text = value;

      This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

      1 Reply Last reply
      0
      • P Pyro Joe

        hi, I know how to format a paragraph programmatically, using "\r" to return to the next line in a rich text box, and continue adding text to the next line. but there are a couple problems I've run into doing this. first, I hate putting a giant paragraph on a single line, cause it makes the (i think it's called) buffer really wide, kinda like not turning on word wrap. Secondly, my main problem is, it takes a long time to insert all the + "\r" + "text "\r", etc. is there an easier way to do this? if not, someone should make a tutorial with an app. I thought about trying to do this myself, but I don't know how to use regular expressions very well, which seems the best way to go about making an app that could do this. that could automatically reveal formatting. Keep in mind, I would like to insert this text at the current cursor position. thanks for the help, Stephen

        P Offline
        P Offline
        Pyro Joe
        wrote on last edited by
        #3

        thanks for the help. I was wandering though,is there a way to actually reveal formatting. like, insert text into one richTextBox and then ouput the text with the formatting symbols ("\r\n"), or the thing you showed me in a second richTextBox? This would be very very helpful to me. thanks again.

        P 1 Reply Last reply
        0
        • P Pyro Joe

          thanks for the help. I was wandering though,is there a way to actually reveal formatting. like, insert text into one richTextBox and then ouput the text with the formatting symbols ("\r\n"), or the thing you showed me in a second richTextBox? This would be very very helpful to me. thanks again.

          P Offline
          P Offline
          Pyro Joe
          wrote on last edited by
          #4

          ok I think I figured it out. one thing though, how do I insert the text "\r\n" as text, without using it as actual formatting.

          S 1 Reply Last reply
          0
          • P Pyro Joe

            ok I think I figured it out. one thing though, how do I insert the text "\r\n" as text, without using it as actual formatting.

            S Offline
            S Offline
            S Senthil Kumar
            wrote on last edited by
            #5

            You can escape them like "\\r\\n" or use the verbatim modifier @"\r\n". Regards Senthil My Blog

            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