5
I have a RichTextBox
that needs to count the breaks of lines as "\r\n"
, but she’s counting as "\n"
.
Example:
"Hello, (User squeezes Enter)world!"
To RichTextBox
interpret like this:
"Olá," + "\n" + "mundo!"
And I need:
"Olá," + "\r\n" + "mundo!"
I had done the following, so that at the time I save the text of RichTexBox
, the breaks were as "\r\n"
: I send the text of RichTexBox
to an array of strings called TextoTraduzido
(In case you can go saving the texts in the array), and:
for (int i = 0; i < (TextoTraduzido.Length); ++i)
{
string TextoTraduzidoSeparado = TextoTraduzido[i].Split(separadores, StringSplitOptions.RemoveEmptyEntries);
TextoTraduzido[i] = string.Join(System.Environment.NewLine, TextoTraduzidoSeparado);
}
That solved the problem at first, but then I noticed that I also need the line break to look like "\r\n"
while the user is typing.
The typed text will be part of a hexadecimal code, it cannot contain more or less characters. " r n" are two characters and " n" is only one. For example, if I type a text with 6 characters and a line break, man label
with RichTextBox1.Text.Length
will count as 7 instead of 8. Until I copy and paste the text from RichTextBox
for another text editor, the text will be less characters, and need these values in the correct format.
There is no way to change the line break character of RichTextBox
? Or else, what would be the best way to replace the "\n"
for "\r\n"
while the user types?
Why do you need to replace while the user type? What’s the point?
– João Martins
@Joãomartins, I edited the question. Take a look there please
– Moonslate
Right, so just replace the character " n" when you fetch the value of
RichTextBox
, right?– João Martins