C# dynamically add event handler

后端 未结 5 793
感动是毒
感动是毒 2020-12-17 08:40

Hi i have a simple question. here is my code:

        XmlDocument xmlData = new XmlDocument();
        xmlData.Load(\"xml.xml\");

        /* Load announceme         


        
5条回答
  •  北海茫月
    2020-12-17 09:45

    Well, if I understand your question correctly, your "needs help" section should become this:

    item.Click += new EventHandler(item_click);
    

    then you just need to add a function to your class:

    public void item_click(object sender, EventArgs e)
    {
       //do stuff here
    }
    

提交回复
热议问题