Hi,
I have a RichTextBox control and this Form code:
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...VB Code:
Imports System.Text.RegularExpressions Public Class Form1 Private Sub RichTextBox2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox2.TextChanged Dim text As String text = RichTextBox2.Text Dim re As New Regex("(bold)") text = re.Replace(text, "{\b $1}") text = "{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard " & text & "}" RichTextBox2.Clear() RichTextBox2.SelectedRtf = text End Sub End Class
Also, the Enter key for newlines is not working. Help?




Reply With Quote