C # Designed doesn't recognize custom event in user control

I have problems with the VS2012 designer. I have a user control that I created, and it has a text box (among other things) where the user must enter IPv4, IPv6 or DNS. I needed to check this text as a valid (TextChanged event) report for the main program. Consider the following code:

private bool addressError;

public EventHandler ErrorChanged;

public bool Error
{
    get
    {
       return addressError;
    }
    set
    {
        if (this.Error != value)
        { 
            addressError = value;
            OnErrorChanged(this, EventArgs.Empty);
        }
    }
}

protected virtual void OnErrorChanged(object sender, EventArgs e)
{
    if (ErrorChanged != null)
    {
        ErrorChanged(sender, e);
    }
}

Then I add an event handler to the main program developer (the control name is "Com"):

this.Com.ErrorChanged += new System.EventHandler(this.Com_ErrorChanged);

The problem is that although the code works exactly the way I wanted it, the designer believes that there is no event ErrorChanged. The exact message he reports is

The type "ModbusCom.Communications" does not have the name "ErrorChanged".

, ok. , , , , . -, , ? !

+5
1

:

public EventHandler ErrorChanged;

public event EventHandler ErrorChanged;
+7

All Articles