Presentation is loading. Please wait.

Presentation is loading. Please wait.

Understand Windows Forms Inheritance 98-362 Windows Development Fundamentals LESSON 2.2.

Similar presentations


Presentation on theme: "Understand Windows Forms Inheritance 98-362 Windows Development Fundamentals LESSON 2.2."— Presentation transcript:

1 Understand Windows Forms Inheritance 98-362 Windows Development Fundamentals LESSON 2.2

2 98-362 Windows Development Fundamentals LESSON 2.2 Lesson Overview How can developers apply Windows ® forms inheritance in applications? In this lesson, you will learn about:  Reasons for using forms inheritance  Inheriting forms within the Designer  Inheriting forms in code

3 98-362 Windows Development Fundamentals LESSON 2.2 Anticipatory Set  List qualities that you have inherited from your parents. Which of your features are similar to your parents? Which of your features are different?

4 98-362 Windows Development Fundamentals LESSON 2.2 Visual Inheritance in Forms  Allows the developer to create multiple forms that share common elements and functionality Two primary reasons for using forms inheritance:  Reusability  Consistency

5 98-362 Windows Development Fundamentals LESSON 2.2 Reusability  If multiple forms will have a similar appearance, the design work can be done once and then shared.  A change (or correction) needs to be made only once—the other forms automatically “inherit” the changes. Consistency  Forms inheritance make it easy to keep forms looking consistent, just as the template in a Microsoft PowerPoint presentation ensures that each slide looks consistent.

6 98-362 Windows Development Fundamentals LESSON 2.2 Inheritance Terminology  Base (or parent) form: A form that is used to define one or more additional forms  The form on which other forms will be “based”  Inherited (or child) form: A form that is based on (or “inherits from”) a base form Base Child 1Child 2Child 3

7 98-362 Windows Development Fundamentals LESSON 2.2 frmContact frmSalesLead frmClient frmContact is the base form. frmSalesLead and frmClient are inherited forms—they will “inherit” elements (buttons, labels, etc.) from the base class. Changes to controls in frmConact will result in the same changes on frmSalesLead and frmClient (when the project is rebuilt).

8 98-362 Windows Development Fundamentals LESSON 2.2 Notes:  Each inherited form can be modified independently.  — The base form can define the common elements (buttons for “New,” “Save,” and “Delete,” for example) so that they don’t have to be duplicated manually.  Changes to the base form are reflected on all inherited forms when the project is built, not when the base form is saved.  — To build a base form, choose Build Solution from the Build menu.

9 98-362 Windows Development Fundamentals LESSON 2.2 Forms Inheritance with the Designer 1. The project must first be built (by selecting Build Solution from the Build menu). 2. Choose Add Windows Form from the Project menu (or by right-clicking the project name in the Solution Explorer). 3. Select Inherited Form (from the Windows Forms category), choose a name, and click Add. 4. The Inheritance Picker will open and display all forms from the current project. 5. Select the base form and click OK.

10 98-362 Windows Development Fundamentals LESSON 2.2 Forms Inheritance in Code  Where the form’s class is declared, add a reference to the base form (including namespace) using Inherits (in Visual Basic ® ) or : (in C# ® )  Visual Basic: Public Class frmClient Inherits frmContact  C#: public class frmClient : frmContact

11 98-362 Windows Development Fundamentals LESSON 2.2 Lesson Review  What is forms inheritance?  Why is forms inheritance useful to developers?  How can you create an inherited form using the Designer?  How can you create an inherited form programmatically?


Download ppt "Understand Windows Forms Inheritance 98-362 Windows Development Fundamentals LESSON 2.2."

Similar presentations


Ads by Google