handle all keypress

M

Matteo Gabella

Hi all,
i have to handle all the controls of the form at one time, because the
'keypreview' property of the form is missing so I need to implement
myself...
because of that I want to concentrate all the keypress event of the
controls in a generic controls_keypress...
it'easy, but what if I have 50 controls on the form? Do I have to
write

Private Sub controls_keypress (ByVal sender As System.Object,
ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles _
Txt1.KeyPress, _
Txt1.KeyPress, _
.....
Txt50.KeyPress

Or is there a faster way? Should I use controls arrays? Controls
collection?

Thank you
matteo
 
J

Jimmy Page

try with the AddHandler featurs

es: AddHandler pc.KeyPress, AddressOf Controls_KeyPress
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top