How to call an event manually in C#?

前端 未结 6 1852
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-17 21:02

I have a USerControll in which i have a textbox. I use the usercontrol in my form, I want to do something when somebody presses enter on the textbox. how can I do it? if you

6条回答
  •  轮回少年
    2020-12-17 21:09

    I was looking for an answer to this issue for me,

    just do this

    examble:

    //this is the call to trigger the event:
    
     **lst_ListaDirectorios_SelectedIndexChanged(this, new EventArgs());**
    
    //do that if you have the method signature in the same class as I do. (something like this below)
    private void lst_ListaDirectorios_SelectedIndexChanged(object sender, EventArgs e)
            {
              //do something
             }
    

    I hope this was useful for you.

提交回复
热议问题