如何在Gotfocus事件中验证 [英] How Can I Validate In A Gotfocus Event

查看:58
本文介绍了如何在Gotfocus事件中验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在gotfocus事件中验证时,验证会自动多次触发请帮助我

when i am trying to validate in gotfocus event the validation fires automatically multiple times please help me

推荐答案

为什么你可能想要验证GotFocus事件中的任何内容?正如CHill60所说,每当控件获得焦点时它就会被触发 - 换句话说,你会在之前立即验证它用户有机会输入他的数据:这是你应该的数据验证!



要么使用LostFocus事件,要么使用适当的Changed事件进行任何控制。甚至是Validating事件,一些控件也有。
Why would you possibly want to validate anything in a GotFocus event? As CHill60 says, it is fired every time the control gets the focus - in other words, you would be validating it immediately before the user got a chance to enter his data: which is the data you should be validating!

Either use the LostFocus event, or an appropriate Changed event for whatever control you are using. Or even the Validating event, which some controls also have.


这篇关于如何在Gotfocus事件中验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆