What works for me after changing a bit of the code from @Danial
int lineCount = LogTextBox.LineCount;
if (lineCount > 300)
{
int excessLines = lineCount - 300;
var text = LogTextBox.Text;
int removeIndex = 0;
for (int i = 0; i < excessLines; i++)
{
removeIndex = text.IndexOf(Environment.NewLine, removeIndex) +
Environment.NewLine.Length;
}
LogTextBox.Text = text.Substring(removeIndex);
}