开发者

.net winforms TextBox programmatically press enter

How can I programmatically create Enter button press in .NET WinForms? I want on TextChanged event initialize Ente开发者_C百科r button press without user interrupt. Thanks


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.


You can do it like this

button1_Click(null, null)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜