检查Button是否单击

检查Button是否单击

本文介绍了检查Button是否单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个文本框,其中有一个事件可以触发查询



我想知道如何检查按钮是否单击以便当我单击按钮时,文本框事件将不会触发查询



我尝试过使用MouseHover事件按钮和布尔值,但文本框事件仍然执行



对不起,如果我没有添加我的代码







在我的文本框离开事件

Hi
I have a Textbox with an event of Leave that fires query

I want to know how to check if a button is click so that when I ever I click the button the textbox event won't fire the Query

I've tried using a MouseHover event for the button and a boolean but the textbox event still execute

sorry if I didn't add my code



On my Textbox Leave event

Dim chkBtnStatus As Boolean

Private Sub TxtboxLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtBox.Leave
If chkBtnStatus Then
    Dim MainMenu As New MainForm
    Me.Close
    MainMenu.Show
    Exit Sub
End If
RunQuery()
End Sub





其中



Where

Public Sub RunQuery()

Select familyName From Contacts Where FirstName = '" & Textbox.Text & "'
//Lets jump to the result skipping the command and datareader codes
FamilyNameLbl.Text = DataRead(0).ToString

End Sub





在我的Button.Click事件中



Inside my Button.Click Event

chkBtnState = True





以上代码完美无缺

我的客人我的计划将无法工作

离开事件将始终激活



The above codes works perfectly fine
I guest my Plan won't work
Leave event will always fire

推荐答案


Public Class form1
  Private hasBeenClicked As Boolean
  Private Sub btn_Clicked(...) Handles btn.Click
    If Not hasBeenClicked Then
       'do query
    End If
    hasBeenClicked = True
  End Sub
...
End Class


这篇关于检查Button是否单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 17:31