Click here to Skip to main content
15,789,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, my code/event is losing link with control. I create the controls and such, I double click and insert my code, but when I compile and execute the commands they don't work, so I go back to the control, double click on it but it creates a new event ignoring the existing one.


Windows 11
Microsoft Visual Studio Enterprise 2022 V. 17.5.0 Preview 6.0
Structure .Net7

What I have tried:

I tried to create the event again, but it doesn't solve it, it keeps losing the link.
I tried to create form from scratch, but it continues.
Updated 12-Feb-23 10:21am
0x01AA 12-Feb-23 11:57am    
Publish your code in question in your question. Nobody here is keen click a link.
Dave Kreskowiak 12-Feb-23 15:17pm    
Don't post screenshots of the code. Just copy and paste the code.

We have no access to your system - so we have no way to check exactly what you have done. And your need to be looking at your system to even start working out what is happening.

So create a new solution, add a WinForms project, and drop a button on the form.
Double click the button and add a MessageBox.Show call to the handler that it creates for you.
Test it several times. I'm guessing it will work.

Now add your menustrip and an item. Repeat the exercise above for the Click handler.
Again, I'm guessing it will work. We can't do that because we don't have your menu control or any idea what it contains or does!

If it does work, you have a problem elsewhere in your code which is affecting your original project.
If it doesn't start look at the menu control itself.

Sorry, but we can't do any of that for yoU!
Share this answer
Member 11663142 12-Feb-23 16:08pm    
Hello, thanks for the feedback, but as I said, I've done this several times, redoing the project from scratch, but this always happens at a certain point, as I add new components.

I've always used .NET Framework, now I'm using .NET 7.0 for the first time and this is already happening. Forgot to mention that I'm using, not sure if that could be the fault of the devexpress add-on or .net 7.00

I requested support directly with them, maybe they will help.
The two subs you highlighted don't have Handles clauses on them. They have no idea they are supposed to handle events without them.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

The same goes for the menu toolstrip Click, but I don't know what ever that one is supposed to handle.
Share this answer
Member 11663142 12-Feb-23 20:48pm    
Hello, exactly, it doesn't have Handles, but it did in all of them, and it's losing by itself. So imagine the inconvenience losing the Handles, it's causing me a huge problem, I add them all, and after a while it loses them all again.
Dave Kreskowiak 13-Feb-23 0:03am    
I've never had them disappear on their own, EXCEPT when I delete methods handling events and improperly add them back.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900