remove a specific line in richtextbox c# 1

remove a specific line in richtextbox c#

List Lines = richTextBox.Lines.ToList();
int lineToRemove = 0;
Lines.RemoveAt(lineToRemove);
richTextBox.Lines = Lines.ToArray();

Here is what the above code is Doing:
1. Convert the lines in the RichTextBox to a List.
2. Remove the first line from the List.
3. Convert the List back to an array and assign it to the RichTextBox.

Similar Posts