79332527

Date: 2025-01-06 08:48:04
Score: 1.5
Natty:
Report link

@Bohdan Kulish works fine and is cleaner but will delete the bottom part of the text. here is the code if you want to delete the top part

int lineCount = LogTextBox.LineCount;
        if (lineCount > 300)
        {
            string res = "";
            List<string> lines = new List<string>();

            for (int line = lineCount-1; line > 300; line--)
            {
                // GetLineText takes a zero-based line index.
                lines.Add(LogTextBox.GetLineText(line));
                res += LogTextBox.GetLineText(line) + "\n";
            }
            LogTextBox.Text = res;

        }
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Bohdan
  • Looks like a comment (1):
  • Low reputation (0.5):
Posted by: Danial