Okay... I'm writing a .NET CF (VBNET 2008 3.5 SP1) application, which has one master form, and it dynamically loads specific UserControls based on menu click, in a sort of framework idea.
There are certain methods and properties these controls all need to work within the app.
Right now I am doing this as an Interface, but this is aggravating as all get up, because some of the methods are optional, and yet I MUST implement them by the nature of interfaces.
I would prefer to use inheritance, so that I can have certain code be inherited with overridability, but if I write a class which inherits System.Windows.Forms.UserControl
and then inherit my control from that, it squiggles, and tells me that UserControls MUST inherit directly from System.Windows.Forms.UserControl
. (Talk about a design flaw!)
So next I thought, well, let me use a partial class to extend System.Windows.Forms.UserControl
, but when I do that, even though it all seems to compile fine, none of my new properties/methods show up on my controls.
Is there any way I can use partial classes to 'extend' System.Windows.Forms.UserControl
?
For example, can anyone give me a code sample of a partial class which simply adds a MyCount As Integer
readonly property to the System.Windows.Forms.UserControl
class? If I can just see how to get this going, I can take it from there and add the rest of my functionality.
Thanks in advance! I've been searching google, but can't find anything that seems to work for UserControl extension on .NET CF. And the Interface method is driving me crazy as even a small change means updating ALL the controls whether they need to 'override' the method or not.
EDIT: I'm looking really for a way to do simply code inheritance if possible, without visual inheritance. My controls share no common visual elements, I really only need to inherit common functionality in the code-behind.