by BlackCat (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 23rd September 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
One HandleEvent Procedure/Hander can handle multiply control event handle. -create a simple handleEvent procedure -using AddHandler
System.EventArgs)
'your common doubleclick handling code here
end sub
AddHandler textbox1.DoubleClick, AddressOf myDoubleClick
AddHandler textbox2.DoubleClick, AddressOf myDoubleClick
AddHandler textbox3.DoubleClick, AddressOf myDoubleClick
in the second method, you could loop through all your controls, check
whether its a textbox
and then use AddHandler.
something like...
for each oControl in Me.Controls()
if typeOf oControl is TextBox then
AddHandler oControl.DoubleClick, AddressOf myDoubleClick
end if
next oControl
======================================================
\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
doset(Me)
End Sub
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
If TypeOf ctr Is Textbox then
AddHandler ctr.DoubleClick, AddressOf MyDoubleClick
end if
doSet(ctr)
Next
///
No comments have been posted about One HandleEvent Procedure/Hander can handle multiply control event handle. -create a simple handleE. Why not be the first to post a comment about One HandleEvent Procedure/Hander can handle multiply control event handle. -create a simple handleE.