The property that you are checking (txtNewNotes.Text
) is for all the text in the TextBox (All the text from all the lines combined).
What you will need to check is the txtNewNotes.Lines
property that returns a string[]
of each line that is contained inside your TextBox. Iterate through those strings and check their lengths.
Remember that with your current code, you are only adding a new line at the end of the TextBox.
You will need to handle the case where a user goes back to a line in the middle of the TextBox and starts editing a line there, making that specific line longer than your 50 character limit and causing an undesired amount of new lines at the end of the TextBox