@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;
}