Losing control Handles code

BugMan

Well-known member
Joined
Dec 27, 2010
Messages
52
Location
Tallahassee FL
Programming Experience
10+
Just about every day as I build my app and run/test it, I click on a control (button, grid, anything) and nothing happens. I double-click the control in design mode, and it's like clicking on a new control, no code is there.

It turns out that the control loses the part of the line of code... in other words this:
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

turns into this:

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

"Handles Button1.Click" is lost.

This has happened so often that I know I'm not deleting it accidentally. Am I doing something else wrong? Has anybody else had this problem? It is extremely frustrating!
 
No, I've never seen that happen in any VS version, not even once.

Something that is similar, but not what you describe, is if you select a control and cut (Ctrl-X) and then paste (Ctrl-P) it elsewhere, then all Handles will be lost since the control is in effect removed from the form. If this is something you inadvertently are doing then you can drag-drop the controls instead.
 
No, I've never seen that happen in any VS version, not even once.

Something that is similar, but not what you describe, is if you select a control and cut (Ctrl-X) and then paste (Ctrl-P) it elsewhere, then all Handles will be lost since the control is in effect removed from the form. If this is something you inadvertently are doing then you can drag-drop the controls instead.

These are controls that I haven't touched in days. When I double click on it to see why it's not firing, there is a "_1" tacked onto the name of the control like this(in red below) and the sub is empty. The other one still exists, and all I have to do is to add the "Handles Button1.Click" to the end again and it works again.

VB.NET:
Private Sub Button1_[COLOR="red"]Click_1[/COLOR](ByVal sender As System.Object, ByVal e As System.EventArgs)
 
why it's not firing
Perhaps your firing fried it!? hahahah.. Yeah, I know, you meant why the event isn't raised. Well, I have no other ideas about that.
 
propably a vs virus id suggest reinstalling it, had a similar one, when i viewed my form code and design there was nonthing except for
VB.NET:
Public Class frm1
End Class
but when i ran the form, everything displayed at run-time. Also had another one which crashed vs everytime i debugged, i had to press ctrl+f5 everytime i wanted to run my app.
 
I can now reproduce this error of losing button event "Handles..." code. If I Cut the toolstrip hosting the buttons from the form, and then Paste it back, and then examine the event code, then button click event, or any other event such as mouse hover, etc., loses its 'Handles' code on the end of the line, of course disabling the button completely. The code is not lost but I must add the 'Handles' part of the line back in manually.
 
In fact, the Button does not even need to be on a toolstrip. I just drew a button on the form, added a messagebox in the click event, cut the button and pasted it back, and the same thing occurred.
 
I told you so... ;)
me said:
if you select a control and cut (Ctrl-X) and then paste (Ctrl-P) it elsewhere, then all Handles will be lost since the control is in effect removed from the form. If this is something you inadvertently are doing then you can drag-drop the controls instead.
 
Back
Top