Answer the question
In order to leave comments, you need to log in
How to remove extra spaces in RichTextBox without resetting formatting?
I remove unnecessary problems with the following command:
RichTextBox.Text = Regex.Replace(RichTextBox.Text, "[ ]+", " ");
bool onespace = false;
for (int i = 0; i < RichTextBox.TextLength; i++)
{
if (RichTextBox.Text[i] == ' ')
{
//если перед этим тоже был пробел..
if (onespace )
{
RichTextBox.Text.Remove(i);
}
else
onespace = true;
}
else
onespace = false;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question