如何在单击两个控件处于禁用状态的组合框或文本框后输出消息框。 任何方法将不胜感激! 谢谢你
答案 0 :(得分:0)
您可以使用MouseDown事件形式:
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If TextBox1.Enabled = False AndAlso _
e.X >= TextBox1.Left And e.X <= TextBox1.Left + TextBox1.Width AndAlso _
e.Y >= TextBox1.Top And e.Y <= TextBox1.Top + TextBox1.Height Then
MsgBox("The textbox is disabled")
End If
If ComboBox1.Enabled = False AndAlso _
e.X >= ComboBox1.Left And e.X <= ComboBox1.Left + ComboBox1.Width AndAlso _
e.Y >= ComboBox1.Top And e.Y <= ComboBox1.Top + ComboBox1.Height Then
MsgBox("The combobox is disabled")
End If
End Sub