views:

53

answers:

2

Suppose I have a base form Main1 which may need to be altered slightly, including perhaps adding additional Controls and altering the size/location of existing Controls. Those base Controls which I need to alter I set to 'protected' in the designer. So I have another form, Main2, that derives from Main1. Then I have another form, Main3, which has even more additions/alterations but needs the additions of the 2nd form. And so forth. My inheritance chain looks like: MainX : Main(X - 1) : ... : Main2 : Main1

This works great and allows me to have designer support when moving around and resizing Controls, but I am always wary of inheritance in general and especially when I have a chain this big.

Am I going to pay for this later?

+1  A: 

Inheritance is your friend.

Another approach would be to use nested master pages, which may make more sense depending on your application. I'd avoid creating new classes just to change control size or other markup-related content.

David Lively
+1  A: 

I've done this a lot in the past (admittedly not much past 3 or so levels deep) and it's worked pretty well. From time to time the controls seemed to disappear in my "inheriting" form (normally at creation time), but that was back in VS2002/2003 and .net 1.0/1.1. As long as I could call up the finished form successfully (i.e. all controls present and correct) everything was OK.

davek