左侧输入要复制的字符串,点击复制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();

 

posted on 2015-07-13 17:12  新猪先生  阅读(1175)  评论(0编辑  收藏  举报