Pass an event into a constructor
- by Vaccano
I have a class that I want to be able the handle the mouse up event for a grid.
I tried to create it with a static method call like this:
MyDataBinding.BindObjectsToDataGrid(ListOfObjectsToBind, myGrid.MouseUp);
The end goal being that in the method I would assign a delegate to the MouseUp
PassedInMouseUp += myMethodThatWillHandleTheMouseUp;
Looks good here (to me) but the compiler chokes on the first line. It says that I can only use MouseUp with a += or a -=.
Clearly I am going about this the wrong way. How can I get a different class to handle the mouse up with out having to:
Pass in the whole grid
Expose the method that will be handling the mouse up as a public method.
Or, is this just a limitation and I will have to do one of the above?