Okay, here’s a good one for you,
So I’ve developed a custom control based which inherits from System.Windows.Forms.Combo
box, which allows users to select a color from the drop down. This control is based off the one on the copeproject website linked below:
The control worked beautify… until I realized I needed to put it inside a ToolStrip (face palm). So I made a copy of the control and made it inherit from ToolStripComboBox. All the code basically stayed the same, the only changes I had to make were that some of the events and properties of the ToolStripComboBox that I needed were only accessible through the ToolStripComboBox.ComboBox
property. So the only thing I had to change was that one or two of the subs handed Combobox.EventName instead of Me.EventName.
This control also worked perfectly, but then I realized I needed to change something, so I went into the code for the ToolStripComboBox color picker and made the change. Off course then I realized I had to make the same change in the original ComboBox color picker. After another few changes that I realized I needed to make, I started to get pretty annoyed at the fact that I needed to write the same pieces of code twice over.
This is normally when you would use a base class; one class that both controls inherit from. The only problem is that I need access in this class to the base members of the ComboBox class. In order to get those base members, I would have to allow my base class to inherit System.Windows.Forms.Combo
box. But then I couldn’t inherit this base class in my ToolStrip color picker class, because it needs to inherit ToolStripComboBox.
So I’m not exactly sure what to do here. I need the same members in both classes with the same code in each, but they need to inherit from different from different classes.