Results 1 to 3 of 3

Thread: [2008] RichTextBox does not allow newlines&backspace throws cursor into end of text.

  1. #1

    Thread Starter
    Addicted Member kaisellgren's Avatar
    Join Date
    Jan 2006
    Posts
    149

    [2008] RichTextBox does not allow newlines&backspace throws cursor into end of text.

    Hi,

    I have a RichTextBox control and this Form code:

    VB Code:
    1. Imports System.Text.RegularExpressions
    2.  
    3. Public Class Form1
    4.     Private Sub RichTextBox2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox2.TextChanged
    5.         Dim text As String
    6.         text = RichTextBox2.Text
    7.  
    8.         Dim re As New Regex("(bold)")
    9.         text = re.Replace(text, "{\b $1}")
    10.  
    11.         text = "{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard " & text & "}"
    12.  
    13.         RichTextBox2.Clear()
    14.         RichTextBox2.SelectedRtf = text
    15.     End Sub
    16. End Class
    If you try it, you will notice that it works nicely for word 'bold' but if u try to backspace (remove) anything in the middle of the text, it throws the cursor back to end...

    Also, the Enter key for newlines is not working. Help?

  2. #2
    Lively Member
    Join Date
    May 2008
    Posts
    117

    Re: [2008] RichTextBox does not allow newlines&backspace throws cursor into end of te

    u should not exchange the whole text each time.
    the best, i think is, only to change the word which is just written. This is quit complicated, but it reduces flickering.

    It seemed to me on http://geekswithblogs.net/pvidler/ar...10/14/182.aspx there are very efficient approaches published. Dont worry about c#, u can use a codeconverter, eg http://codeconverter.sharpdevelop.ne...Converter.aspx
    whats the benefit of beeing rated?


  3. #3

    Thread Starter
    Addicted Member kaisellgren's Avatar
    Join Date
    Jan 2006
    Posts
    149

    Re: [2008] RichTextBox does not allow newlines&backspace throws cursor into end of te

    Quote Originally Posted by Nerd44
    u should not exchange the whole text each time.
    the best, i think is, only to change the word which is just written. This is quit complicated, but it reduces flickering.

    It seemed to me on http://geekswithblogs.net/pvidler/ar...10/14/182.aspx there are very efficient approaches published. Dont worry about c#, u can use a codeconverter, eg http://codeconverter.sharpdevelop.ne...Converter.aspx
    Very interesting links, thank you mate !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width