Friday, May 30, 2014

How to delete a line from a textbox?

Hello,


One method to delete a line at a specific index



Dim DeleteIndex As Integer = 2
If txtLines.Lines.Length > DeleteIndex Then
txtLines.Lines = txtLines.Lines.Where(
Function(w)
Return w <> txtLines.Lines(DeleteIndex)
End Function).ToArray()
Else
MessageBox.Show("Not enough elements to remove element " &
DeleteIndex.ToString)
End If

Above screenshot



Perhaps I want to remove the first line only



txtLines.Lines = txtLines.Lines.ToList.Skip(1).ToArray





Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.


No comments:

Post a Comment