Windows Develop Bookmark and Share   
 index > Windows Forms Designer > my project lost "handles" clause for a ton of controls...anyone else had this happen?
 

my project lost "handles" clause for a ton of controls...anyone else had this happen?

I am experiencing an issue with visual studio 2008 but cannot reproduce it, so I have yet to submit a bug report. I was hoping someone in this forum has seen or experienced the same issue and can explain what causes it to happen?

When I copy sections of code from one project to another it seems to fail to copy the "handles" part of my procedures. Both of the projects were the same code, same controls & id's. I was just moving some new functionality into a current production version. I am running vs2008 professional on my dev box and the production box was running the vs2008 standard version.

I attempted to find another post on the web about this happening, but I wasn't able to come up with anything. What makes this annoying is that I had to go back and add about 20 "handles" clauses for buttons that already existed. However, I took a backup of my code and tried the same things again today and it all worked fine. So I have NO CLUE what is going on. But I don't like the idea of having to double check things that I copy/paste, I do a lot of code re-use....a LOT.

if anyone has any idea what is wrong please let me know. I have repeatedly done these same types of actions for vs2005 and vs2003, so that is what tells me that something is not right when it doesn't work right in vs2008.

thanks!
Vegeta4ss  Sunday, April 19, 2009 10:45 PM

Hi Vegeta4ss,

In Visual Studio 2008, each form has two cs file. For Form1, one is Form1.cs and another is Form1.Designer.cs. The form class will be marked as partial class. When you copy the control of a form, you need to copy all the code in the Form1.cs as well as the code in the Form1.Designer.cs. If you lost any line of code, you may get problem. Also you should make sure all the assembly references are added properly.

Before you copy the Form1 from one project to another, you need to create a Form1 in that project first in order that Visual Studio will create the necessary source for it. After copy, you can try to rebuild the project first, if no error occur, then you can click the form to view it in the designer.

Did you do the copy as my description? What does the "handles" really mean in your post?

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Tuesday, April 21, 2009 6:17 AM

Hi Vegeta4ss,

In Visual Studio 2008, each form has two cs file. For Form1, one is Form1.cs and another is Form1.Designer.cs. The form class will be marked as partial class. When you copy the control of a form, you need to copy all the code in the Form1.cs as well as the code in the Form1.Designer.cs. If you lost any line of code, you may get problem. Also you should make sure all the assembly references are added properly.

Before you copy the Form1 from one project to another, you need to create a Form1 in that project first in order that Visual Studio will create the necessary source for it. After copy, you can try to rebuild the project first, if no error occur, then you can click the form to view it in the designer.

Did you do the copy as my description? What does the "handles" really mean in your post?

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Tuesday, April 21, 2009 6:17 AM
you write a routine and you choose an event for this routine to "handle" such as a click event. I use VB.net, so it is probably called something different in c#.

In my case I was running two different versions of the same project. When I copied over the newer code all of the event handlers were not hooked up. So when I clicked my buttons nothing happened. I had to manually go back and add "handles btnUpdateSomething.Click" to almost 40 different controls. I have seen this behavior before when copying over code that references controls that do not exist, but this was the same project and all of the controls existed already.

Do you understand my issue now?

It has not happened again. I cannot reproduce the problem. So I suppose I will mark this resolved.
Vegeta4ss  Friday, April 24, 2009 12:54 PM

You can use google to search for other answers

Custom Search

More Threads

• adding a listviewgroup programmically
• User control, designer says "The variable 'integratedSearchView1' is either undeclared or was never assigned"
• order of radio buttons
• VB.NET 2005 *ERROR* DESIGNER LOADER DID NOT PROVIDE ROOT COMPONENT
• label with select text and copy functionality similar like textbox
• Gah! The designer is filling in my properties for me!!
• How to highlight a row on selecting a row on tablelayoutpanel
• Error initializing form containing button with image
• external callback
• Expose DataSet within Component