EventHandler with custom arguments

后端 未结 3 1789
自闭症患者
自闭症患者 2020-12-05 20:21

I\'ve been looking for an answer for about an hour on Google but I did not found exactly what I\'m looking for.

Basically, I have a static Helper class that helps pe

3条回答
  •  失恋的感觉
    2020-12-05 21:06

    Honest admission up front: I have not tried the code below.

    I think the reason

    menuItemFolder.Click += new System.EventHandler(menuItemFolder_Click(sender,e,owner,dataType));
    

    won't work is because you are actually passing to System.EventHandler () the result of the invocation of menuItemFolder_Click () with the parameters provided. You are not passing a pointer to the function itself.

    Try to write another function that implements the details of menuItemFolder_Click (). See if something like

    private void menuItemFolder_Click_Helper (object sender, EventArgs e, object Owner, object DataType) {
    // implement details here
    }
    

    and then call the function from within menuItemFolder_Click ().

提交回复
热议问题