开发者

How to prevent duplicate code generation when placing winforms event handlers in other partial files

In a winforms application I have a MyForm.cs that starts to get quite large. To solve this I have created a new file(MyForm.LeftPanel.cs) using partial class of the MyForm class with a subset of the GUI functionality.

However once in a while, not always, when I go into the designer all event handlers that I have moved to MyForm.LeftPanel.cs gets regenerated in MyForm.cs with empty functions. This obviously causes compiler error until I manually remove them in MyForm.cs.

How can I prevent these functions 开发者_高级运维from being regenerated?

I saw a question about Placing these kind of files under the main.cs in the project, could this be the solution that would tell visual-studio to find the existing functions?


Using the method in WinForm partial classes I placed MyForm.LeftPanel.cs below MyForm.cs.

So far this seem to have solved the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜