when we add a control on RichTextBox, we can write the text on it's back. but how can i avoid it?
can protect the text using a rectangle?
i have these code that works fine only when the text it's empty:
Code:
Public Sub InsertControl(ByVal ctrlControl As Control)
Me.Controls.Add(ctrlControl)
Dim LineIndex As Integer = Me.GetLineFromCharIndex(Me.SelectionStart)
Dim s As Point = Me.GetPositionFromCharIndex(LineIndex)
If LineIndex > 0 Then
CaretPosition = New Point(CaretPosition.X, CaretPosition.Y - 2)
Me.SelectionProtected = True
CaretPosition = New Point(CaretPosition.X, CaretPosition.Y + 1)
Me.SelectionProtected = True
CaretPosition = New Point(CaretPosition.X, CaretPosition.Y + 1)
Me.SelectionProtected = True
End If
For i As Integer = s.Y To s.Y + ctrlControl.Height
Me.SelectionProtected = True
Me.SelectedText = vbNewLine
i += Me.SelectionFont.Height
If i >= (s.Y + Me.Height) Then Exit For
Next
Me.SelectionProtected = False
ctrlControl.Location = s
End Sub
'Me' it's an Usercontrol(my PlusRichTextBox that Inherits from RichTextBox
can anyone advice me?