[RESOLVED] Change a text in richtextbox but keep image in it
I have a richtextbox with images and text.
I want to change specified text but i want to keep my image.
How can i do that.
I use :
Dim aLines() As String = rtbDisplay.Lines
aLines(i) = aLines(i).Replace(str, "")
rtbDisplay.Lines = aLines
but do not work.
Re: Change a text in richtextbox but keep image in it
You can't using Lines I don't think. You'll have to find the text you want to replace, set SelectionStart and SelectionLength, then set SelectedText.
Re: Change a text in richtextbox but keep image in it
OK. THANKS JM.
I resolved :
Code:
Private Sub Hamthaydoidong(ByVal str As String)
Dim aLines() As String = rtbDisplay.Lines
If aLines(rtbDisplay.Lines.Length - 2).Contains(str) = True Then
rtbDisplay.SelectionStart = rtbDisplay.Text.IndexOf(str)
rtbDisplay.SelectionLength = str.Length
rtbDisplay.SelectedText = "":duck:
End If
End Sub