Home All Groups Group Topic Archive Search About

How to call an event when the "Delete" button is pressed?

Author
19 Nov 2007 9:45 AM
DORI
Dear ALl,
I want to call an event when the user click on the "Delete" button (below
the "Insert" button) of the keyboard while working on the Form1. How can I do
that?
Thank you in advance for any comments.
DORI

Author
19 Nov 2007 11:20 AM
Michael C
"DORI" <D***@discussions.microsoft.com> wrote in message
news:C5D46316-2BF5-412E-BD8D-2587ABE6FCF7@microsoft.com...
> Dear ALl,
> I want to call an event when the user click on the "Delete" button (below
> the "Insert" button) of the keyboard while working on the Form1. How can I
> do
> that?
> Thank you in advance for any comments.
> DORI

Have a look at Form_KeyPress or Form_KeyDown. You can select them from the
combobox at the top right of the code window. Select "Form" in the top left
combo.
Author
19 Nov 2007 12:04 PM
Larry Serflaten
"DORI" <D***@discussions.microsoft.com> wrote
> Dear ALl,
> I want to call an event when the user click on the "Delete" button (below
> the "Insert" button) of the keyboard while working on the Form1. How can I do
> that?

Set the form's KeyPreview property to True.  It will then get the keyboard
events before any of the controls.  To watch for the Delete key, test for it
in the form's KeyDown or KeyUp event.  If you want to stop further processing
(not pass the key on to the active control) set the KeyCode value to 0, otherwise
leave it alone for the active control (editing a textbox perhaps?) to respond
as normal...

HTH
LFS
Author
19 Nov 2007 8:48 PM
DORI
Dear Larry,
Thank you so much for your help. I was not changing the form's keypreview
property to True. After I followed your directions, it worked perfect.
Thanks again,
DORI

Show quoteHide quote
"Larry Serflaten" wrote:

>
> "DORI" <D***@discussions.microsoft.com> wrote
> > Dear ALl,
> > I want to call an event when the user click on the "Delete" button (below
> > the "Insert" button) of the keyboard while working on the Form1. How can I do
> > that?
>
> Set the form's KeyPreview property to True.  It will then get the keyboard
> events before any of the controls.  To watch for the Delete key, test for it
> in the form's KeyDown or KeyUp event.  If you want to stop further processing
> (not pass the key on to the active control) set the KeyCode value to 0, otherwise
> leave it alone for the active control (editing a textbox perhaps?) to respond
> as normal...
>
> HTH
> LFS
>
>
>