PC Review


Reply
Thread Tools Rate Thread

Disabling events

 
 
dave mann
Guest
Posts: n/a
 
      18th Nov 2004
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



 
Reply With Quote
 
 
 
 
Peter Proost
Guest
Posts: n/a
 
      18th Nov 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
dave mann
Guest
Posts: n/a
 
      18th Nov 2004
Brilliant...many thanks

Dave


"Peter Proost" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >
> >

>
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      18th Nov 2004
"dave mann" <(E-Mail Removed)> schrieb:
>[...]


I /hate/ those multiposts...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change in cell disabling events J Streger Microsoft Excel Programming 1 22nd May 2008 08:35 PM
Disabling All Day Events =?Utf-8?B?VGFsbFBhdWw=?= Microsoft Outlook Calendar 0 14th Mar 2007 12:32 PM
Disabling Events: Dangerous? JakeyC Microsoft Excel Programming 1 26th Oct 2005 10:12 PM
Disabling Events Patrick Simonds Microsoft Excel Programming 3 5th Oct 2005 12:35 PM
Disabling Events MWE Microsoft Excel Programming 4 6th Feb 2004 05:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:12 AM.