Chapter 4 (Web design service) Control Structures: Part 1 125 Collapsed

Chapter 4 Control Structures: Part 1 125 Collapsed code Collapsed comment Fig. 4.16 IDE showing program code for Fig. 2.15. immediately by the class name (ASimpleProgram). Recall that the form s name is set using the (Name) property. A colon (:) indicates that the class ASimpleProgram inherits existing pieces from another class. The class from which ASimpleProgram inherits here, System.Windows.Forms.Form appears to the right of the colon. In this inheritance relationship, Form is called the base class (or superclass), and ASimpleProgramis called the derived class (or subclass). With inheritance ASimpleProgram s class definition has the attributes (data) and behaviors (methods) of class Form. We discuss the significance of the keyword public in Chapter 6. [Note: Changing a control s name in the Properties window may not change all occurrences of the control s name in the code. The reader should search the code and replace names that were not changed by the IDE. For example, the original form name (and class name) was Form1. Search the code for Form1 and change any remaining instances to ASimpleProgram.] A key benefit of inheriting from class Form is that someone else has previously defined what it means to be a form. The Windows operating system expects every window (e.g., form) to have certain attributes and behaviors. However, because class Form already provides those capabilities, programmers do not need to reinvent the wheel by defining all those capabilities themselves. In fact, class Form has over 400 methods! In our programs up to this point, we have used only one method (i.e., Main), so you can imagine how much work went into creating class Form. The use of the colon to extend from class Form enables programmers to create forms quickly. In the editor window (Fig. 4.16), notice the text Windows Form Designer generatedcode, which is colored gray and has a plus box next to it. The plus box indicates that this section of code is collapsed. Although collapsed code is not visible, it is still part of the program. Code collapsing allows programmers to hide code in the editor, so that they can focus on smaller (and perhaps more important) code segments. Notice that the entire class definition also can be collapsed by clicking the minus box to the left of public. In Fig. 4.16, the description in gray indicates that the collapsed code was created by the Windows Form Designer (i.e., the part of the IDE that creates the code for the GUI). This collapsed code contains the code created by the IDE for the form and its controls, as well as code that enables the program to run. Click the plus box to view the code.
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

Leave a Reply