multiline programmatically formatting text
-
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
-
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
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. TheEnvironment.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 useEnvironment.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]
-
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
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.
-
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.
-
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.
You can escape them like "\\r\\n" or use the verbatim modifier @"\r\n". Regards Senthil My Blog