2
I’m doing a program for selling products and I have a design problem. The differential of this program is that it can take on two different faces: one for the sale of chocolates and the other for the sale of fruit. The forms I organized more or less this way:
I organized this way so that I could copy the behavior of the base forms, since they are exactly the same at this point and only change visually.
The problem is that the controls of one form are not always the same as another. For example, a button Come back in the mode of chocolates is a Button
, but in the fruit is a PictureBox
, so I need to associate them in some way with the behavior of the base form.
I thought I’d put properties like Control
in the base forms and then I would only make the association in each form, but it seems that it will get a bit messy, since I would also have to make the registration of events Click
manually. I don’t have much confidence that it will become easy to maintain.
Has anyone ever tried to do anything like this and has any tips?
Why don’t you make an intermediate class and just implement the
click
?– Jéf Bueno
You can declare the back button to be of a common base type between the buttons of the two forms. Then you add the button in the form at a runtime event, searching for the instance of the button in a virtual property implemented by each child form. Anyway form inheritance is very laborious and difficult to maintain (as any other inheritance actually). I would seek simpler alternatives.
– Caffé
What do you mean, jbueno?
– Vítor Martins