Reputation: 399
How can I programmatically create Enter button press in .NET WinForms? I want on TextChanged
event initialize Enter button press without user interrupt.
Thanks
Upvotes: 1
Views: 2508
Reputation: 599
System.Windows.Forms.Button
PerformClick
myButton.PerformClick();
That will perform a click on myButton. I'd look into why you need to fake a button click, perhaps you could refactor to avoid this?
EDIT: On second thoughts, perhaps you meant the Enter key. In this case you could use:
SendKeys.Send("{ENTER}");
Still look into the need for this though, it isn't something you should normally have to do.
Upvotes: 2