单击后,VB NET组合框和文本框响应消息

时间:2013-09-28 02:39:37

标签: vb.net combobox textbox messagebox

如何在单击两个控件处于禁用状态的组合框或文本框后输出消息框。 任何方法将不胜感激! 谢谢你

1 个答案:

答案 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