First, is the above block of code EXACTLY repeated in every textchanged event?
If so, the first step you can make towards reducing your code overhead is to take the above code block and place it into a separate function like so:
private void updRTB()
{
string l_text = "";
l_text = textBox1.Text;
l_text += textBox2.Text;
l_text += textBox3.Text;
l_text += textBox4.Text;
...
richTextBox1.Text = l_text;
}
and simply call that component from each textchanged event instead of having it appear separately in each one.
Second, unless you need a "real time" update of the RTB contents each time one of the 170 textboxes is changed you really don't need to fire it for every single textchanged event. However as this seems to be what you're going for I would further simplify by creating a collection out of the textboxes and cycling through that collection with the newline inserted every 10th cycle of the loop. Something like:
for (int a = 0; a < textBoxCollection.Count; a++)
{
l_text += textBoxCollection[a].ToString();
if ((a % 10) == 0)
{
l_text += "\n";
}
}
But I leave it up to you to figure out the collection process :twisted:
Hope that helps :) Please remember to mark as solved once your issue is resolved.