473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Disabling events

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

Nov 21 '05 #1
3 1500
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

Nov 21 '05 #2
Brilliant...many thanks

Dave
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:Oc*************@TK2MSFTNGP14.phx.gbl...
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


Nov 21 '05 #3
"dave mann" <da*******@blueyonder.co.uk> 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/>
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Don | last post by:
is there any way to disable the controls on a form without changing their appearance? i would like to make it impossible for a user to click buttons and edit text boxes while the controls retain...
20
by: dukeleto | last post by:
I know this is an annoying thing on some sites. I have set some images in an online gallery to have their own java po up window that is set to be the same size as the image. I would like to...
5
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
0
by: Josef Meile | last post by:
Hi I wanted to programmatically disable events like SelectedIndexChanged without using a boolean flag, which indeed I find a quick and dirty solution. So, I found a piece of code that do this...
3
by: PB | last post by:
What is the rationalle for disabling JavaScript. AFAIK, the primary reason is for "security purposes" - but what specific kind of threats does the protect against? AND - is the disabling of...
6
by: Roger Uribe | last post by:
There are references to using the wndproc form sub to trap and swallow the mousewheeel events - but they don't get there when a combobox (or many other controls) has the focus.. Yet the MSDN does...
12
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation...
0
by: R. MacDonald | last post by:
Hello, Group, I have an application that contains a large number of controls of a few different types (all custom defined). During certain specific drag-drop operations, I would like to be able...
5
by: jehugaleahsa | last post by:
Hello: I am sure this question comes up a lot. I need to disable the controls on my Windows forms so that when the BindingSource is empty some the controls bound to it will be disabled. This...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.