![](/img/trans.png)
[英]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.