126 Control Structures: Part 1 Chapter 4 Expanded (Web site hosting)

126 Control Structures: Part 1 Chapter 4 Expanded code Fig. 4.17 Windows Form Designer generated code when expanded. Upon initial inspection, the expanded code (Fig. 4.17) looks incredibly complex.This code is created by the IDE and normally is not edited by the programmer. We feel it is important for novice programmers to see the amount of code that is generated by the IDE, even though much of the code is not explained until later in the book. This type of code is present in every Windows application. Allowing the IDE to create this code saves the programmer considerable development time. If the IDE did not provide the code, the programmer would have to write it, and this would require a considerable amount of time. The vast majority of the code shown has not been introduced yet, so you are not expected to understand how it works. However, certain programming constructs, such as comments and control structures, should be familiar. Our explanation of this code will enable us to discuss visual programming in greater detail. As you continue to study C#, especially in Chapters 8 13, the purpose of this code will become clearer. When we created this application in Chapter 2, we used the Properties window to set properties for the form, label and picture box. Once a property was set, the form or control was updated immediately. Forms and controls contain a set of default properties, which are displayed initially in the Properties window when a form or control is selected. These default properties provide the initial characteristics of a form or control when it is created. When a control, such as a label, is placed on the form, the IDE adds code to the class (e.g., ASimpleProgram) that creates the control and that sets some of the control s property values, such as the name of the control and its location on the form. Figure 4.18 shows a portion of the code generated by the IDE for setting the label s (i.e., welcomeLabel s) properties. These include the label s Font, Location, Name, Text and TextAlign properties. Recall from Chapter 2 that we explicitly set values for the label s Name, Text and TextAlign properties. Other properties, such as Location are set only when the label is placed on the form.
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply