I have two text boxes
and a button in windows form app
using c#
.
when i enter text in txtbox1
and send that text to txtbox2
on button click event
, the cursor also goes to txtbox2
.
My requirement is when i send data from textBox1
to textBox2
on buton click event the cursor should remain in textBox1
.
In the buttonClick event just add at the end:
textBox1.Focus();
Any reasons why dont set cursor position manually after the click event?
Cursor.Position = new Point(MyFirstTextbox.Location.X -5, MyFirstTextbox.Location.Y -5);
Also Control.Focus() helps you.
On button click write at last:
textbox1.focus()
focus
is the method you need to use.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.