Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Back in this book’s early chapters, we learned about object-oriented programming and how to inherit objects from prebuilt classes. We learned that each form is nothing more than a class that inherits from System.Windows.Forms.Form. Taking the concept of inheritance a step further, we can easily inherit from a base form to create identical child forms. Why is the ability to do this so great? How many times have you had to re-create the look and feel of a form for your company? Now this task becomes trivial using visual inheritance.
Let’s say you have a form that your company wants to use to present a common look and feel throughout its applications. You could develop a base form that you can inherit from and make any specific changes on child forms that inherit from the base. In a base company form, we might have an About button that’s private and can’t be overridden in a child form. This way we can have a consistent About statement on all forms. We could also provide a link to our Web site that can’t be overridden in a child form. On the other hand, it might be helpful to inherit the Help button in child forms so that context-sensitive help can be provided on each child form. Our base form might look something like Figure 14-1.