textbox获取当前光标位置,在光标后面插入字符串

  

左侧输入要复制的字符串,点击复制btn,将左侧字符串复制到后侧,

示例:

输入框                复制后

12345      12345 (光标落在3后)

aaa        123aaa45(光标落在4后)

bbb        123aaa4bbb5

            //先获取复制文本
            string newstr = textBox1.Text;


            //获取textBox2 中的光标
            int index = textBox2.SelectionStart;
            textBox2.Text = textBox2.Text.Insert(index, newstr);
            textBox2.SelectionStart = index +newstr.Length;
            textBox2.Focus();
原文地址:https://www.cnblogs.com/zychengzhiit1/p/4643387.html