[英]How can I set the cursor position at the new line which is after the last line in a multiline textbox using C#?
[英]How to set cursor position in textBox on button click event using c#?
我在windows form app
使用c#
有两个text boxes
和一个按钮。
当我在txtbox1
输入文本并将button click event
上的文本发送到txtbox2
时,光标也将移至txtbox2
。
我的要求是,当在click事件上将数据从textBox1
发送到textBox2
时,光标应保留在textBox1
。
有什么原因导致单击事件后不手动设置光标位置?
Cursor.Position = new Point(MyFirstTextbox.Location.X -5, MyFirstTextbox.Location.Y -5);
Control.Focus()也可以帮助您。
在按钮上单击最后写入:
textbox1.focus()
focus
是您需要使用的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.