I have a text box in a windows form and it is fill with text. I have got the cursor to the right spot, but I need to know how to code a enter button press?
all I wanted it to do was bring what ever was in front of the cursor down on to the next line.
I'm not a fan of SendKeys. Sendkeys will not work in your situation.
When you click on the button, the button receives focus, when you click, it fires the on_click event. The on_click event calls sendkeys.send("{ENTER}"). And since the button now has focus, the enter keystroke is sent to the button. Which then fires the on_click event, which calls sendkeys.send, and on and on and on.
If you want to use send keys, make sure to set the focus to the textbox immediately before sending the send key. But I would recommend using substring and inserting an environment.newline value instead.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.