troubleshooting Question

Rich Text Box - Insert Text at a specific position

Avatar of bertino12
bertino12 asked on
Visual Basic.NET
1 Comment1 Solution1660 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros