Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event Handler References Getting Deleted???

Status
Not open for further replies.

cjtaylor

Programmer
Aug 12, 2001
69
0
0
US
I have a program where I have several control event handlers being implemented. I have a serious, tedious problem that keeps occurring in Visual Studio 2005 Team C#.

When I switch from the code view to design view and the form is redrawn/reconstructed or whatever happens when the form is displayed in design mode, my event handlers (not all but most of them) get deleted from the mainform.designer.cs file! This happens maybe once out of 15-20 time when switching back and fourth.

When this happens, obviously all my button clicks and other events become broken and I have to manually add these event handlers back to the file, which is extemely time consuming.

Has anyone else experienced this problem, or knows of a solution?
 
I have experienced the problem before, even in VS 2003. The solution is to hand code the link to the event. Since it isn't designer code anymore, it won't ever be deleted.

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
Are you saying to move the events from the designer class to the form class where the event is consumed?

Thanks
 
Are you changing the designer code? In VS2003 the InitializeComponent() method should never be touched. Otherwise VS deletes it.

I imagine the same is true with 2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top