Section 2.4. Navigating the Visual Studio IDE


2.4. Navigating the Visual Studio IDE

The IDE provides windows for accessing project files and customizing controls. In this section, we introduce several windows that you will use frequently when developing Visual Basic programs. These windows can be accessed via the toolbar icons (Fig. 2.13) or by selecting the name of the desired window in the View menu.

Figure 2.13. Toolbar icons for three Visual Studio windows.


Visual Studio provides a space-saving feature called auto-hide. When auto-hide is enabled, a tab appears along either the left or right edge of the IDE window (Fig. 2.14). This tab contains one or more icons, each of which identifies a hidden window. Placing the mouse pointer over one of these icons displays that window (Fig. 2.15). The window is hidden again when the mouse pointer is moved outside the window's area. To "pin down" a window (i.e., to disable auto-hide and keep the window open), click the pin icon. When auto-hide is enabled, the pin icon is horizontal (Fig. 2.15); when a window is "pinned down," the pin icon is vertical (Fig. 2.16).

Figure 2.14. Auto-hide feature demonstration.


Figure 2.15. Displaying a hidden window when auto-hide is enabled.


Figure 2.16. Disabling auto-hide ("pinning down" a window).


The next few sections overview three of the main windows used in Visual Studiothe Solution Explorer, the Properties window and the Toolbox. These windows show information about the project and include tools that help you build your programs.

2.4.1. Solution Explorer

The Solution Explorer window (Fig. 2.17) provides access to all of the files in a solution. If the Solution Explorer window is not shown in the IDE, you can display it by clicking the Solution Explorer icon in the IDE (Fig. 2.13), by selecting View > Solution Explorer or by typing <Ctrl> <Alt> L. When Visual Studio is first run, the Solution Explorer is empty; there are no files to display. Once you open a new or existing solution, the Solution Explorer displays the contents of the solution.

Figure 2.17. Solution Explorer with an open project.


The solution's startup project is the project that runs when the program executes. If you have multiple projects in a given solution, you can specify the startup project by right-clicking the project name in the Solution Explorer window, then selecting the Set as StartUp Project. For our single-project solution, the startup project is the only project (in this case, WindowsApplication1) and the project name appears in bold text in the Solution Explorer window. We discuss only single-project solutions in this text. For programmers using Visual Studio for the first time, the Solution Explorer window lists only the My Project and Form1.vb files (Fig. 2.17). The Solution Explorer window includes a toolbar that contains several icons.

The Visual Basic file that corresponds to the form shown in Fig. 2.4 is named Form1.vb (selected in Fig. 2.17). Visual Basic files use the .vb filename extension, which is short for "Visual Basic."

By default, the IDE displays only files that you may need to editother files generated by the IDE are hidden. When clicked, the Show All Files icon (Fig. 2.17) displays all the files in the solution, including those generated by the IDE (Fig. 2.18). The plus and minus boxes that appear can be clicked to expand and collapse the project tree, respectively. Click the plus box to the left of My Project to display items grouped under the heading to the right of the plus box (Fig. 2.19); click the minus box to collapse the tree from its expanded state (Fig. 2.20). Other Visual Studio windows also use this plus-box/minus-box convention.

Figure 2.18. Solution Explorer showing plus boxes and minus boxes for expanding and collapsing the tree to reveal or hide project files.


Figure 2.19. Solution Explorer expanding the My Project file after clicking its plus box.


Figure 2.20. Solution Explorer collapsing all files after clicking any minus boxes.


2.4.2. Toolbox

The Toolbox contains icons representing controls used to customize forms (Fig. 2.21). Using visual programming, programmers can "drag and drop" controls onto the form, which is faster and simpler than building them by writing GUI code (we discuss writing this type of code in Chapter 5, Control Statements: Part 1). Just as you do not need to know how to build an engine to drive a car, you do not need to know how to build controls to use them. Reusing pre-existing controls saves time and money when you develop programs. You will use the Toolbox when you create your first program later in the chapter.

Figure 2.21. Toolbox window displaying controls for the Common Controls group.


The Toolbox groups the prebuilt controls into categoriesAll Windows Forms, Common Controls, Containers, Menus & Toolbars, Data, Components, Printing, Dialogs and General are listed in Fig. 2.21. Again, note the use of plus and minus boxes which can expand or collapse a group of controls. We discuss many of the Toolbox's controls and their functionality throughout the book.

2.4.3. Properties Window

To display the Properties window if it is not visible, select View > Properties Window, click the Properties window icon shown in Fig. 2.13, or press the F4 key. The Properties window displays the properties for the currently selected Form (Fig. 2.22), control or file in design view. Properties specify information about the form or control, such as its size, color and position. Each form or control has its own set of properties; a property's description is displayed at the bottom of the Properties window whenever that property is selected.

Figure 2.22. Properties window.


Figure 2.22 shows Form1's Properties window. The left column lists the form's properties; the right column displays the current value of each property. You can sort the properties either alphabetically (by clicking the Alphabetical icon) or categorically (by clicking the Categorized icon). The properties can be sorted alphabetically from AZ or ZA; sorting by category groups the properties according to their use (i.e., Appearance, Behavior, Design, etc.). Depending on the size of the Properties window, some of the properties may be hidden from view on the screen. Users can scroll through the list of properties by dragging the scrollbox up or down inside the scrollbar, or by clicking the arrows at the top and bottom of the scrollbar. We show how to set individual properties later in this chapter.

The Properties window is crucial to visual programming; it allows you to modify a control's properties visually, without writing code. You can see which properties are available for modification and, in many cases, can learn the range of acceptable values for a given property. The Properties window displays a brief description of the selected property, helping you understand its purpose. A property can be set quickly using this window and no code needs to be written.

At the top of the Properties window is the component selection drop-down list, which allows you to select the form or control whose properties you wish to display in the Properties window (Fig. 2.22). Using the component selection drop-down list is an alternative way to display a form's or control's properties without selecting the actual form or control in the GUI.



Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net