473,327 Members | 1,930 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,327 software developers and data experts.

Handler question

I have several textboxes and I want one dbl click handler to be used for all
of the textboxes. How do I get all of the text boxes to use the same dbl
click
handler?

Kim
Nov 20 '05 #1
3 977
Private Sub DoubleClickHandler(ByVal sender As Object, ByVal e As
System.EventArgs) _

Handles TextBox1.DoubleClick, TextBox2.DoubleClick, TextBox3.DoubleClick,
TextBox4.DoubleClick

Dim tb As TextBox = DirectCast(sender, System.Windows.Forms.TextBox)

MsgBox(String.Format("Text in {0}:{1}{2}", tb.Name, Environment.NewLine,
tb.Text), _

MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "You double-clicked " +
tb.Name)

End Sub

hth,

Luhar

"Kim C" <ki***@cox.net> wrote in message news:EaeOc.137$73.30@lakeread04...
I have several textboxes and I want one dbl click handler to be used for all of the textboxes. How do I get all of the text boxes to use the same dbl
click
handler?

Kim

Nov 20 '05 #2
private sub myDoubleClick(byval sender as object, byval e as
System.EventArgs) handles _
textbox1.DoubleClick, textbox2.DoubleClick, textbox3.Doubleclick
'your common doubleclick handling code here
end sub

Or...

private sub myDoubleClick(byval sender as object, byval e as
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

the syntax for the above might me wrong...sorry. Just wanted to give you the
idea..

hope this helps..
Imran.
"Kim C" <ki***@cox.net> wrote in message news:EaeOc.137$73.30@lakeread04...
I have several textboxes and I want one dbl click handler to be used for all of the textboxes. How do I get all of the text boxes to use the same dbl
click
handler?

Kim

Nov 20 '05 #3
Hi Kim,

The rest te same as the other answers from Luthar and Imran a quick method
to set the handler to all textboxes.

\\\
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
///

I hope this helps?

Cor
Nov 20 '05 #4

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

Similar topics

0
by: Novice | last post by:
Hey all, I've already posted this question and two posters offered suggestions and they worked - but now I would like to know why - and if possible the answer to a second question. Here is my...
2
by: Jukka Aho | last post by:
When converting Unicode strings to legacy character encodings, it is possible to register a custom error handler that will catch and process all code points that do not have a direct equivalent in...
3
by: wolverine | last post by:
Hi, I am injecting a javascript code into html pages and attaching some dom events to some elements via attachEvent (IE only). I just want to know that is there any chance by which my event...
16
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.