Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter code

Status
Not open for further replies.

Xgamer911

Technical User
Jun 15, 2005
7
0
0
US
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.
 
it is already a multiline text box. I just need to know how to code a enter button press, but thank you for your help.
 
I must said it wrong.

If I hit enter, yes it enters to the next line. It works that way no problem.

I need a way for the code to do it without me hitting enter.
 
Use the: SendKeys.Send("{ENTER}")

when ever I put this into a separate button with no other code, the program locks up and crashes.

any ideas
 
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.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top