What I want to do is delete the last line in a RichTextBox.
The RichTextBox has a ReadOnly property called lines that seems like it
might help but I cant figure out how to use it.
Well, the question is what is the easiest way to remove the last line in a
RichTextBox?
Thanks
Hi
The easiest way is to move the cursor to the beginning of the desired
line. Next hold down the delete key until all characters have been
removed.
Hope this helps.
The Grand Master
> What I want to do is delete the last line in a RichTextBox.
>
[quoted text clipped - 5 lines]
>
> Thanks
Franky - 21 Nov 2006 15:46 GMT
Thanks but my fault, I meant programmatically
> Hi
>
[quoted text clipped - 15 lines]
>>
>> Thanks
I don't know about the [lines] property, but assuming that each
line in the RichTextBox has a carriageReturn/LineFeed combination
at the end of it, this should work.
Private Sub RemoveLastLine()
Dim myData() As String
Dim crlfs() As String = {ControlChars.CrLf}
Dim lines As String = myRichTextBox.Text
'split it by crlf
myData = lines.Split(crlfs, StringSplitOptions.None)
're-join it without the last line
Dim outputString As String = _
String.Join(ControlChars.CrLf, myData, 0, myData.Length - 1)
myRichTextBox.Text = outputString
End Sub
Robin S.
---------------------------------
> What I want to do is delete the last line in a RichTextBox.
>
[quoted text clipped - 5 lines]
>
> Thanks
Franky - 21 Nov 2006 15:51 GMT
Thanks, that looks good.
>I don't know about the [lines] property, but assuming that each
> line in the RichTextBox has a carriageReturn/LineFeed combination
[quoted text clipped - 23 lines]
>>
>> Thanks