Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / November 2006

Tip: Looking for answers? Try searching our database.

How to remove the last line in a RichTextBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Franky - 20 Nov 2006 19:22 GMT
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
Master Programmer - 21 Nov 2006 06:02 GMT
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
RobinS - 21 Nov 2006 08:20 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.