Why is handles on event missing?

  • Thread starter Thread starter Brett
  • Start date Start date
B

Brett

I'm using a third part component in a certain app. The component has
methods and events. I noticed one particular event was not firing after a
while but it should have been. The problem was the "handles" part was
missing. I didn't remove this that I know of. After putting this back in,
the event started firing.

Actually, the code inside the event wasn't firing but the "private sub
eventname()" part was being hit. By putting a breakpoint there, I found the
handles part was missing.

How else could this have gone missing?

Thanks,
Brett
 
Brett,

If you create a Sub for a particular control's event, let's say a button
click event, then subsequently delete the control, the sub for the click
event will remain, but since the control was deleted, the "Handles
Button.click" will be missing.

Once you add the control back to the form, even if you give it the same
name, you'll have to go back to each of the event subs for the control and
add the "handles control.event"

HTH
Lee
 
No exactly. If you then add a control after its been removed with the same
name & double-click it to get the click event up for example then you will
notice a number appended to the end. Example:

Button1_Click(...) Handles...

Button1_Click1(...) Handles...

well, at least that what it does on all my machines with VS.NET 2003 Ent.
Arch installed.

Crouchie1998
BA (HONS) MCP MCSE
 
I agree that if you remove a control, rebuild the project, and add a control
with the same name (say "Button"), if you double-click the control to add
the click event, the new sub name will have a 1 appended.

However, the original sub will be missing "Handles Button.Click", because
the project was rebuilt without a reference to the control named "Button".

For the click event, there are two choices to fix the missing "Handles".
Double-click on the new control to create a new click event sub, then
cut/paste the code from the original click event, then delete the original
click event, or just add the "Handles Button.Click" back to the original
sub.

For other subs related to the added control, you can recreate them,
cut/paste, etc., or just add the "Handles Control.Event".

But, in response to the original question asked, the "Handles" disappear if
a control is deleted from the form, and the project is re-built. Adding the
same control with the same name back to the form does not add the "Handles
Control.Event" back to any existing subs.

Cheers,
Lee
 

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

Back
Top