Whenever I made changes to a form in the designer, it seems that VS is removing all of the handle statements from events. I've had to code them all manually using AddHandler in the form's constructor to keep them there. Any insights?
Example:
Private Sub cboEntity_SelectionChangeCommitted(sender As Object, e As EventArgs) '<NOW MISSING> Handles cboEntity.SelectionChangeCommitted
If cboEntity.SelectedItem IsNot Nothing Then
RaiseEvent ID_Changed(Me, cboEntity.SelectedItem)
End If
End Sub
Current Version:
Microsoft Visual Studio Community 2022 Version 17.5.2 VisualStudio.17.Release/17.5.2+33502.453 Microsoft .NET Framework Version 4.8.09032
Installed Version: Community
Azure App Service Tools v3.0.0 17.5.317.37931 Azure App Service Tools v3.0.0
C# Tools 4.5.0-6.23128.14+651d32d8017cfcc60fcbd67383601fa9a3deb145 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
NuGet Package Manager 6.5.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Visual Basic Tools 4.5.0-6.23128.14+651d32d8017cfcc60fcbd67383601fa9a3deb145 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.5.0-beta.23053.5+794b7c259d9646a7eb685dad865aa27da7940a21 Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.
I have had to code all of my handlers manually in the form's constructor...
AddHandler cboEntity.SelectionChangeCommitted, AddressOf Me.cboEntity_SelectionChangeCommitted
This has been going on for at least several weeks. Anyone else notice the problem? Is it specific to vb.net as opposed to c#?
Any help appreciated
This was a known issue in VS. You say that you are using VS v17.5.2. It's my understanding that this issue was fixed in v17.5.3, while the most current version is 17.5.4. If you update VS, this issue should not arise again.
As for fixing your code, there's nothing that will do it automatically, other than rolling back your changes. If you don't have a backup anywhere, you're out of luck. This is an example of why everyone, no matter their level, should be using source control. Then you could simply roll back your changes. I suggest that you look into source control options. Free options include Azure DevOps and GitHub, but there are others too.
To fix your code, you can either add the Handles clause back to each event handler manually, or you can use the Properties window to select an existing method for each relevant event.