Visual Studio .NET - Open and Open With . . .
(Page 7 of 10 )
These commands allow you to open the current item, i.e., the item currently selected in the Solution Explorer (described later in this section), in the program of your choice. Open uses the default editor, and Open With allows you to pick from a list of programs. You can add other programs to the list.
The Open With command also lets you open an item with the editor of your choice in Visual Studio .NET. For example, you can open a file in the binary viewer when you might normally get the resource viewer. Perhaps most usefully, you can also specify the default editor for an item. For example, you can make a web form open in code view rather than design view by default.
Solution Explorer (Ctrl+Alt+L) Projects and solutions are managed using the Solution Explorer, which presents the solution and projects, and all the files, folders, and items contained within them, in a hierarchical, visual manner. The Solution Explorer is typically visible in a window along the upper right side of the Visual Studio .NET screen, although the Solution Explorer window can be closed or undocked and moved to other locations.
To view the Solution Explorer if it is not already visible, select View -> Solution Explorer from the Visual Studio .NET menu. Alternatively, press the Ctrl+Alt+L keys simultaneously. A typical Solution Explorer is shown in Figure 2-11.

Figure 2-11. Solution Explorer
There are several menu buttons along the top of the Solution Explorer window. These buttons are context-sensitive (i.e., they may appear or may not appear, depending on what is the currently selected item in the Solution Explorer). Table 2-7 details the purpose of each button.
Table 2-7. Solution Explorer buttons
| Button Name | Shortcut keys | Description |
| View Code | F7 | Displays code in main window. Only visible for source files. |
| View Designer | Shift +F7 | Displays visual designer in main window. Only visible for items with visual components. |
| Refresh | none | Refreshes the Solution Explorer display. |
| Copy Project | None | Presents dialog box for copying a project, with options for copying only the files necessary to run or all the files required for further development work. |
| Show All Files | none | Toggles display of all files in the Solution Explorer. By default, many files are not shown. If Show All Files is clicked, the solution shown in Figure 2-11 will look like Figure 2-12 after all of the nodes have been expanded. |
| Properties | Alt+Enter | If the currently highlighted item is a solution or a project, it displays the Properties page for that item. Otherwise, moves the cursor to the Properties window for that item. |

Figure 2-12. Solution Explorer (expanded)
It is also possible to display miscellaneous files in the Solution Explorer. To do so, go to Tools -> Options…, then go to Environment -> Documents. Check the checkbox labeled Show Miscellaneous files in Solution Explorer.
Most of the functionality of the Solution Explorer is redundant with the Visual Studio .NET menu items, although it is often easier and more intuitive to perform a given chore in Solution Explorer rather than in the menus. Right-clicking on any item in the Solution Explorer will pop up a context-sensitive menu. Three different pop-up menus from Solution Explorer are shown in Figure 2-13. From left to right, they are for a solution, a project, and a source code file.

Figure 2-13. Solution Explorer context-sensitive menus for solutions, projects, and source files
Several points concerning the commands on these pop-up menus deserve mention:
- The Add command for solutions and projects offers submenus that allow new or existing items to be added. These commands are also found on the main Project menu.
- Set Startup Projects and Exclude From Project commands can also be found on the main Project menu.
- The Build and Rebuild commands duplicate commands found on the main Build menu.
- The Debug command submenus include two commands found on the main Debug menu.
- If the Properties item is clicked for a source file, the cursor moves to the Properties window. If the Properties item is clicked for a solution or project, the Property Pages for that item are opened.
Properties Windows (F4) The Properties window displays all the properties for the currently selected item. Some of the properties (such as Font and Location) have subproperties, indicated by a plus sign next to their entries in the window. The property values on the right side of the window are editable.
One thing that can be confusing is that certain items have more than one set of properties. For example, a Form source file can show two different sets of properties, depending on whether you select the source file in the Solution Explorer or the form as shown in the Design view.
A typical Properties window, with the Font subproperty expanded out, is shown in Figure 2-14.

Figure 2-14. Properties window
The name and type of the current object is displayed in the field at the top of the window. In Figure 2-14, it is an object named Label1 of type Label, contained in the System.Web.UI.WebControls namespace.
The Font property has subproperties that may be set either directly in the window or either by clicking on the drop-down or the button with three dots on it.
The Properties window has several buttons just below the name and type of the object. The first two buttons on the left toggle the list by category or alphabetically. The next button from the left displays properties for an object. The rightmost button displays property pages for the object, if there are any.
Some objects have both a Properties window and Property Pages. The Property Pages display additional properties from those shown in the Properties window.
If the project is in C#, then there will be an additional lightening bolt (
button that is used to create event handlers for an item. Events are covered in Chapter 3.
For some controls, such as the Calendar, there is an additional panel as part of the Properties window with verbs, such as AutoFormat.
The box below the list has a brief description of the selected property.
Server Explorer (Ctrl+Alt+S) The Server Explorer allows you to access any server to which you have network access. If you have sufficient permissions, you can log on, access system services, open data connections, access and edit database information, access message queues and performance counters, and more. You can also drag nodes from the Server Explorer onto Visual Studio .NET projects, creating components which reference the data source.
A typical Server Explorer is shown in Figure 2-15. It is a hierarchical view of the available servers. In this figure, there is only one server available, ATH13T. The figure shows a drill-down into SQL Server, showing the tables in the Northwind database. These tables, and all other objects in this tree view, are directly accessible and editable from the window.
Class View (Ctrl+Shift+C) The Class View shows all the classes in the solution in a hierarchical manner. A typical Class View, somewhat expanded, is shown in Figure 2-16. The icons used in this window are listed in Table 2-5 and Table 2-6.
As with the Solution Explorer, any item in the class view can be right clicked, which exposes a pop-up menu with a number of context-sensitive menu items. This can provide a convenient way to sort the display of classes in a project or solution, or to add a method, property or field to a class.
The button on the left above the class list allows for sorting the classes listed, either alphabetically, by type, by access, or grouped by type. Clicking on the button itself sorts by the current sort mode, while clicking on the down arrow next to it presents the other sort buttons and changes the sort mode.
The button on the right above the class list allows you to create virtual folders for organizing the classes listed. These folders are saved as part of the solution in the .suo file.

Figure 2-15. Server Explorer
These folders are virtual (i.e., they are illusory). They are only used for viewing the list. As such, they have no effect on the actual items. Items copied to the folder are not physically moved, and if the folders are deleted, the items in them are not lost. Note that if you rename or delete an object from the code that is in a folder, you may need to manually drag the item into the folder again to clear the error node.
Object Browser (Ctrl+Alt+J) The Object Browser is a tool for examining objects (such as namespaces, classes, and interfaces), and their members (such as methods, properties, variables, and events). A typical Object Browser window is shown in Figure 2-17.

Figure 2-16. Class View
The objects are listed in the pane on the left side of the window, and members of the object, if any, are listed in the right pane. The objects are listed hierarchically, with the ability to drill down through the tree structure. The icons used in this window are listed in Table 2-5 and Table 2-6.
Right clicking on either an object or a member brings up a context-sensitive popup menu with a variety of menu options.

Figure 2-17. Object Browser
This article is excerpted from Programming ASP.NET by Jesse Liberty and Dan Hurwitz(O'Reilly, 2003; ISBN 0596004877). Check it out at your favorite bookstore today. Buy this book now. |
Next: Other Windows >>
More ASP.NET Articles
More By O'Reilly Media