How to add an event to a UserControl in C#?

后端 未结 6 2282
一向
一向 2020-11-27 05:04

I have a UserControl which contains 3 labels. I want to add an event for it, which occurs when the text of one of the labels changed.
I am using Visual Studio 2010

6条回答
  •  天命终不由人
    2020-11-27 05:11

    compile error, which says: "Expected class, delegate, enum, interface, or struct" on the second line it seems to have a problem with "event...


    These 2 lines need to be INSIDE the class declaration.

    public delegate void TextChangedEventHandler(object sender, EventArgs e);
    public event TextChangedEventHandler LabelTextChanged;
    

提交回复
热议问题