如何检查是否在LostFocus时按下了Cmd按钮 [英] How Can I Check If A Cmd Button Was Pressed At LostFocus Time

查看:90
本文介绍了如何检查是否在LostFocus时按下了Cmd按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何检查LostFocus时是否按下了Cmd按钮?

我有一个表单,如果在输入任何内容之前按下了取消"按钮,它将对第一个字段执行LostFocus处理.

如果第一个字段为空白,则会显示错误.
我需要能够判断是否按下了取消"命令按钮,如果是,则绕过LostFocus上的编辑.

我该怎么办?

在此先谢谢您!
Rahul Chitte:)

Hi All,

How Can I Check If A Cmd Button Was Pressed At LostFocus Time?

I have a form that, if the cancel button is pressed before anything is entered, it performs the LostFocus processing for the first field.

If the first field is blank, an error is displayed.
I need to be able to tell if the Cancel command button was pressed and, if so, bypass the edit on the LostFocus.

How can I do this?

Thanks in advanced!
Rahul Chitte :)

推荐答案

嘿,我得到了答案,

在VB6中,有一个名为ActiveControl的属性,它告诉我们当前哪个控件处于活动状态,因此我在textbox_LostFocus事件中编写了以下代码来解决我的问题:

如果(Me.ActiveControl.Name)= cmdCancel.Name然后
卸载我
退出子
如果结束
Hey I got answer,

In VB6 there is one property named ActiveControl which tell us which control is currently active, So i wrote following code in textbox_LostFocus event to resolve my issue :

If (Me.ActiveControl.Name) = cmdCancel.Name Then
Unload Me
Exit Sub
End If


这篇关于如何检查是否在LostFocus时按下了Cmd按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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