I want to bubble an event from a class to a Custom Usercontrol.
My Usercontrol is basically a datasheet.
Sheet
-> List<Row> Rows
->List<Cell> Cells
My UC(Sheet) has a list of Rows(Class) with each Row having a list of Cells(Class). My question is.. How can i raise an event from a Cell that the sheet can catch??
Your cells can raise an event on the sheet, if they are aware of the sheet. For instance:
Of course then each cell must have a way of referencing the sheet that it’s on (using a Sheet property in the example above).
Another, more messy, option would be to have the Sheet subscribe to events on all individual cells. That would be more work, but then at least the Cells don’t have to be aware of the Sheet they are on.
EDIT:
To answer your additional question, performance-wise there wouldn’t really be a difference. The code would be easier to write using the first approach, simply also because your Sheet — or any other object — would only have to subscribe to a single event to receive data from any changing cell (assuming that that is what you want).