Windows forms editor keeps recreating an event method

岁酱吖の 提交于 2020-01-06 19:28:50

问题


I have a C# application with a custom control. The custom control class looks like this:

public partial class DetNumericUpDown : UpDownBase
{
    public event EventHandler ValueChanged;

    /* some public methods */

    public DetNumericUpDown() { /* ... */ }
}

Then I have several instances of DetNumericUpDown in a form file Main.cs, placed from the designer. Each of these instances have their own ValueChanged event defined, but instead of placing them in Main.cs I have moved them for clarity to another file OtherFile.cs. The problem is that each time I try to use the windows forms designer on Main.cs it recreates these methods in Main.cs and then complains the methods are defined twice. That only happens with the DetNumericUpDown instances, as I have moved some event methods from other controls into OtherFile.cs and it works fine. What am I doing wrong?

来源:https://stackoverflow.com/questions/37762519/windows-forms-editor-keeps-recreating-an-event-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!