Inherited grid and controls association problem RRS feed

  • Question

  • Hi all!

    This is a tricky problem I am having. 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


    • Edited by Okash Khawaja Monday, July 20, 2009 9:10 AM To italicise the class names
    Monday, July 20, 2009 9:06 AM

All replies

  • You should consider to build the ButtonsControl as a normal user control. Then you should work with something like the observable pattern and subscribe you grid to the events fired by the user control. Let's say you will have a save_event_handler fired by the user control each time a user press the button save.
    In this way you will need only to modify the user control and both grids will see the changes.
    What do you think about my idea?

    MCAD - MCSD MCTS Sharepoint 2007 MCTS SQL Server 2005 "If my answer is useful remember to mark it as useful".
    Wednesday, July 22, 2009 6:00 PM