Link to home
Start Free TrialLog in
Avatar of bertino12
bertino12

asked on

Rich Text Box - Insert Text at a specific position

I am messing with the RichTextBox. I click in the box and want to get the cursor position.

Then If someone clicks a button it will insert a string at that position in the RichTextBox.

I dont have any code, just want to do this via the button click event. Can someone give me a sample of how to do this?

I have a function that gets the Index and Line, but is that enough to do what I want?



Private Sub btnInsertText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertText.Click
        Dim strText = "Automobile"
        'insert Text at current cursor position in the richtextbox.
    End Sub
 
    Private Sub getRichTextBoxPosition()
        sCursor.intIndex = Me.rtbAmendText.SelectionStart
        sCursor.intLine = Me.rtbAmendText.GetLineFromCharIndex(sCursor.intIndex)
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Muhammad Kashif
Muhammad Kashif
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial