How can I programmatically create Enter button press in .NET WinForms? I want on TextChanged event initialize Enter button press without user interrupt.
Thanks
2 Answers
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.
TextChangedevent will usually be raised on every character and on the enter key press that you fake. What are you actually trying to achieve?