Datasheet

30
CHAPTER 1 VISUAL STUDIO 2010
Visual Studio places all the generated source code for your form in the fi le Form1.Designer.vb . Because
the Designer portion of this name is a convention that Visual Studio recognizes, it hides these fi les by
default when you review your project in the Solution Explorer. As noted earlier, by asking Visual Studio to
show all fi les, you can fi nd these generated fi les. If you open a Designer.vb le, you ll see that quite a
bit of custom code is generated by Visual Studio and already in your project.
To do this, go to the toolbar located in the Solution Explorer window and select the Show All Files button. This
will change your project display and a small plus sign will appear next to the
Form1.vb le. Expanding this entry
displays the Form1.Designer.vb le, which you can open within the IDE. Doing this for Form1.Designer.vb
for the ProVB_VS2010 project you created will result in a window similar to the one shown in Figure 1 - 15.
FIGURE 1 - 15
Note that the contents of this fi le are generated. For now, don t try to make any changes. Visual Studio
automatically regenerates the entire fi le when a property is changed, so any changes you make will be lost.
The following lines start the declaration for your form in the fi le Form1.Designer.vb :
< Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated() > _
Partial Class Form1
Inherits System.Windows.Forms.Form
Code snippet from Form1.Designer
The fi rst line is an attribute that can be ignored. Next is the line that actually declares a new class called Form1 .
Note that in spite of the naming convention used by Visual Studio to hide the generated UI class implementation,
the name of your class and the fi le in which it exists are not tightly coupled. Thus, your form will be referenced
in the code as Form1 unless you modify the name used in the class declaration. Similarly, you can rename the fi le
that contains the class without changing the actual name of the class.
One powerful result of forms being implemented as classes is that you can now derive one form from another
form. This technique is called visual inheritance , although the elements that are actually inherited may not be
displayed.
CH001.indd 30CH001.indd 30 4/5/10 11:56:47 AM4/5/10 11:56:47 AM