Inherited controls' assiciation problem

Hi all!

This is a tricky problem I am having. Please see the attached UML diagram of the scenario. It is described below.

GridB inherits from GridA. ButtonsControl has association with GridA (and hence GridB). It handles events fired by GridA. GridAForm contains (composition) GridA and ButtonsControl. GridBForm contains (composition) GridB and ButtonsControl. If there are any questions regarding the scenario, feel free to ask.

The problem is that ButtonsControl is not a separate control but it is a set of buttons on GridAForm and GridBForm. Therefore, I have to copy ButtonsControl code from GridAForm to GridBForm everytime there is a change in ButtonControls part of GridAForm. If ButtonsControl is made a separate control, how will the events from GridA be handled?

Can someone please suggest a solution to this problem? Any questions, please do ask!

Many thanks

Inherited Grid and Buttons problem.jpg

Why is ButtonsControl listening for events rather than the forms?

I would have GridAForm listening for GridA’s events and GridBForm listening for GridB’s events. Getting rid of the association between ButtonsControl and GridA would make sense to me.