简体   繁体   中英

Check string in textbox with an event?

我想知道在用户点击OK按钮之前是否有办法使用事件来检查Windows窗体中textBox中的字符串?

You can use the KeyDown, KeyPress, or KeyUp event.

A full list of events can be found here: http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox_events.aspx

It's all alphabetical, so scroll down to Key....

A better approach is to use the Validating event of the textbox. This way, your validation routine runs when the user attempts to leave the textbox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM