禁用按钮单击但允许MouseHover?

时间:2015-05-07 13:36:41

标签: vb.net button mousehover isenabled

我有一个检查日志文件的按钮,如果文本与特定字符串不匹配,则按钮被禁用。我是这样做的:

button.enabled = False

这会按预期禁用控件 - 但我想保持启用MouseHover事件。

是否可以禁用点击?

修改

在悬停时更改文字:

Private Sub AIR_Button_MouseHover(sender As Object, e As EventArgs) Handles AIR_Button.MouseHover
    Dim AIRfileReader As String
    AIRfileReader = My.Computer.FileSystem.ReadAllText("X:\Logs\Air\AirConnectedUser.txt")
    AIR_Button.Text = AIR_Button.Text.Replace("Air", AIRfileReader)
End Sub

Private Sub AIR_Button_MouseLeave(sender As Object, e As EventArgs) Handles AIR_Button.MouseLeave
    Dim AIRfileReader As String
    AIRfileReader = My.Computer.FileSystem.ReadAllText("X:\Logs\Air\AirConnectedUser.txt")
    AIR_Button.Text = AIR_Button.Text.Replace(AIRfileReader, "Air")
End Sub

禁用按钮:

Dim fileReader As String
    fileReader = My.Computer.FileSystem.ReadAllText("X:\Logs\ConnectionState.txt")
    If fileReader.Contains("AIR Account logged in") Then
        AIR_Button.BackColor = Color.IndianRed
        AIR_Button.Enabled = False 
End Sub

0 个答案:

没有答案