在VB.net中启用/禁用搜索按钮 [英] Search Button Enabled/Disabled in VB.net

查看:117
本文介绍了在VB.net中启用/禁用搜索按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有一个小问题,但不知道如何解决.

我有3个文本框,一个组合框,一个masked文本框和一个按钮.

我已经成功实现了一个代码,其中当所有文本框,组合框和maskedtextbox均为空白时,该按钮被禁用.好!

但是,当一个人填写这些字段之一时,他可以通过退格键删除一个单词/字符并删除键,或者只是用鼠标将其擦除,所以我希望如果用户这样做,则该按钮将再次被禁用.我的意思是,当他插入字符/单词并使用退格键和Delete键用鼠标或键盘将其擦除时,必须再次禁用该按钮.

帮助,谢谢.

Hello, I have a small problem but don''t know how to solve it.

I have 3 textboxes, one combobox, one maskedtextbox and a button.

I have successfully implemented a code, where when all the textboxes, combobox and maskedtextbox are blank, the button is disabled. Good!

However, when a person wil fill one of these fields, he can erase a the word/character by the backspace and delete key or simply erase it with his mouse, so I want that if the user does this, the button disabled again. I mean when he will insert a character/word and erase it with his mouse or keyboard by using the backspace and delete key, the button must be disabled again.

Help, thank you.

推荐答案

您需要做的是实现一个在每个控件的Leave事件中调用的函数.
这样的东西

What you need to do is implement a function which gets called in each control''s Leave event.
Something like this

Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Leave, TextBox2.Leave, TextBox3.Leave, MaskedTextBox1.Leave, ComboBox1.Leave
        DisableButton()
    End Sub
    Private Sub DisableButton()
        'Disable button here if all controls empty
    End Sub



希望对您有帮助



Hope this helps


这篇关于在VB.net中启用/禁用搜索按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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