place a textbox txtcomp on a form, copy paste the code run the prog and
click inside the textbox, the type the word double in the textbox and double
click it
Private Sub txtComp_MouseDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs)
MsgBox("One click")
End Sub
Private Sub txtComp_DoubleClick(ByVal sender As Object, ByVal e As _
System.EventArgs)
MsgBox("Double click")
End Sub
Private hasHandler As Boolean = True
Private Sub txtComp_TextChanged(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles txtComp.TextChanged
If txtComp.Text = "double" Then
RemoveHandler txtComp.MouseDown, AddressOf txtComp_MouseDown
hasHandler = False
Else
If hasHandler = False Then
AddHandler txtComp.MouseDown, AddressOf txtComp_MouseDown
hasHandler = True
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
_ Handles MyBase.Load
AddHandler txtComp.DoubleClick, AddressOf txtComp_DoubleClick
AddHandler txtComp.MouseDown, AddressOf txtComp_MouseDown
End Sub
hth Peter
"dave mann" <da*******@blueyonder.co.uk> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...
Hi,
Does anyone know if there is there an easy way of programmatically
disabling an event?
I want to enable drag-and-drop on a listbox using the listbox_MouseDown
event but also under certain circumstances allow a listbox_DoubleClick
event.
The Mouse_Down event will supercede the DoubleClick event unless disabled.
Many thanks
Dave