2.4 Navigating the Visual Studio IDE

The IDE provides windows for accessing project files and customizing controls. This section introduces several windows that you’ll use frequently when developing Visual C# apps. Each of the IDE’s windows can be accessed by selecting its name in the View menu.

Auto-Hide

Visual Studio provides an auto-hide space-saving feature. When auto-hide is enabled for a window, a tab containing the window’s name appears along the IDE window’s left, right or bottom edge (Fig. 2.10). Clicking the name of an auto-hidden window displays that window (Fig. 2.11). Clicking the name again (or clicking outside) hides the window. To “pin down” a window (that is, to disable auto-hide and keep the window open), click the pin icon. When auto-hide is enabled, the pin icon is horizontal

as shown in Fig. 2.11. When a window is “pinned down,” the pin icon is vertical

as shown in Fig. 2.12.

Fig. 2.10 Auto-hide feature demonstration.

Fig. 2.11 Displaying the hidden Toolbox window when auto-hide is enabled.

Fig. 2.12 Disabling auto-hide—“pinning down” a window.

The next few sections present three Visual Studio’s windows that you’ll use frequently—the Solution Explorer, the Properties window and the Toolbox. These windows display project information and include tools that help you build your apps.

2.4.1 Solution Explorer

The Solution Explorer window (Fig. 2.13) provides access to all of a solution’s files. If it’s not shown in the IDE, select View > Solution Explorer. When you open a new or existing solution, the Solution Explorer displays the solution’s contents.

Fig. 2.13 Solution Explorer window showing the WindowsFormsApplication1 project.

The solution’s startup project (shown in bold in the Solution Explorer) is the one that runs when you select Debug > Start Debugging (or press F5) or select Debug > Start Without Debugging (or press Ctrl + F5 key). For a single-project solution like the examples in this book, the startup project is the only project (in this case, WindowsFormsApplication1). When you create an app for the first time, the Solution Explorer window appears as shown in Fig. 2.13. The Visual C# file that corresponds to the Form shown in Fig. 2.4 is named Form1.cs (selected in Fig. 2.13). Visual C# files use the .cs file-name extension, which is short for “C#.”

By default, the IDE displays only files that you may need to edit—other files that the IDE generates are hidden. The Solution Explorer window includes a toolbar that contains several icons. Clicking the Show All Files icon (Fig. 2.13) displays all the solution’s files, including those generated by the IDE. Clicking the arrow to the left of a node expands or collapses that node. Click the arrow to the left of References to display items grouped under that heading (Fig. 2.14). Click the arrow again to collapse the tree. Other Visual Studio windows also use this convention.

Fig. 2.14 Solution Explorer with the References node expanded.

2.4.2 Toolbox

To display the Toolbox window, select View > Toolbox. The Toolbox contains the controls used to customize Forms (Fig. 2.15). With visual app development, you can “drag and drop” controls onto the Form and the IDE will write the code that creates the controls for you. This is faster and simpler than writing this code yourself. 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 preexisting controls saves time and money when you develop apps. You’ll use the Toolbox when you create your first app later in the chapter.

The Toolbox groups the prebuilt controls into categories—All Windows Forms, Common Controls, Containers, Menus & Toolbars, Data, Components, Printing, Dialogs, Reporting, WPF Interoperability and General are listed in Fig. 2.15. Again, note the use of arrows for expanding or collapsing a group of controls. We discuss many of the Toolbox’s controls and their functionality throughout the book.

2.4.3 Properties Window

If the Properties window is not displayed below the Solution Explorer, select View > Properties Window to display it—if the window is in auto-hide mode, pin down the window by clicking its horizontal pin icon

The Properties window contains the properties for the currently selected Form, control or file in the IDE. 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. When you select a property, its description is displayed at the bottom of the Properties window.

Fig. 2.15 Toolbox window displaying controls for the Common Controls group.

Figure 2.16 shows Form1’s Properties window—you can view by clicking anywhere in the Form1.cs [Design] 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

Depending on the Properties window’s size, some properties may be hidden from your view. You 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.

Fig. 2.16 Properties window.

The Properties window is crucial to visual app development—it allows you to quickly modify a control’s properties and, rather than writing code yourself, lets the IDE write code for you “behind the scenes.” 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset