The Integrated Development Environment (IDE)

The Visual Studio .NET Integrated Development Environment (IDE) consists of windows for visual design of forms; code-editing windows, menus and toolbars providing access to commands and features; toolboxes containing controls for use on the forms; and windows providing properties and information about forms, controls, projects and the solution.

3.4.1 Layout

Visual Studio .NET is a Multiple Document Interface (MDI) application. It consists of a single parent window, which contains multiple other windows. All menus, toolbars, design and editing windows, and miscellaneous other windows are associated with the single parent window.

Figure 3-3 shows a typical layout of the IDE. This section will cover the overall layout and many of the features that make working with the IDE so productive.

Figure 3-3. Typical IDE layout


The Visual Studio .NET window has a titlebar across the top, with menus below. Under the menus are toolbars with buttons that duplicate many common menu commands. Nearly everything that can be done through menus can also be done with context sensitive pop-up menus, as described below. You can customize the menu and toolbars easily by clicking on Tools Customize.

The toolbars are docked along the top of the window by default. As with many Windows applications, they can be undocked and moved to other locations, either free- floating or docked along other window edges. Move the toolbars by grabbing them with the mouse and dragging them where you want.

Figure 3-3 shows a design view of a Windows Form, with the design window occupying the main area in the center of the screen. This position allows you to create a visual design by dragging and dropping components from the Toolbox along the left side of the screen.

Along the right side of the screen are two windows, both of which will be covered in more detail below. The upper window is the Solution Explorer. Below it is the Properties window. Many other, similar windows, are available to you, as described later.

All of these windows, plus the Toolbox, are resizable and dockable. You can resize them by placing the mouse cursor over the edge you wish to move. The cursor will change to a double arrow resizing cursor, at which point you can drag the window edge one way or the other.

Right-clicking on the titlebar of a dockable window pops up a menu with four mutually exclusive check items:


The window can be dragged and docked along any side of the Visual Studio .NET window.


The window disappears. To see the window againi.e., to unhide ituse the View main menu item.


The window will not dock when dragged against the edge of the Visual Studio .NET window. The floating window can be placed anywhere on the desktop, even outside the Visual Studio .NET window.

You can also double-click on either the titlebar or the tab to dock and undock the window. Double-clicking on the title while docked undocks the entire group. Double-clicking on the tab just undocks the one window, leaving the rest of the group docked.

Auto Hide

The window will disappear, indicated only by a tab, when the cursor is not over the window. It will reappear when the cursor is over the tab. A pushpin in the upper-right corner of the window will point down when Auto Hide is turned off and point sideways when it is turned on.

In the upper-right corner of the window are two icons:


This icon toggles the AutoHide property of the window.

When the pushpin points down, the window is pinned in place; AutoHide is turned off. Moving the cursor off the window will not affect its visibility.

When the pushpin points sideways, AutoHide is turned on. Moving the cursor off the window hides the window. To see the window again, click on the tab, which is now visible along the edge where the window had been docked.


The standard close window icon.

The main design window uses a tabbed metaphori.e., the tabs along the top edge of that window indicate there are other windows below it. (You can change to an MDI style, if you prefer, in Tools Options.) Clicking on the tab labeled test.cs in Figure 3-3, for example, will bring up the screen shown in Figure 3-4, which contains a code window.

Figure 3-4. Code window in IDE


When you switch from a design window to a code window, the menu items, toolbars, and Toolbox change in a context-sensitive manner.

The code window has drop-down lists at the top of the screen for navigating around the application. The left drop-down contains a list of all the classes in the code and the right drop-down has a list of all objects in the current class. In VB.NET you can also use these drop-downs to select event sources (from the lefthand drop-down) and add event handlers (from the righthand drop-down). This also works in the HTML editor.

Along the bottom edge of the IDE window is a status bar, which shows such information as the current cursor position (when a code window is visible), the status of the Insert key, and any pending shortcut key combinations.

3.4.2 Menus and Toolbars

The menus provide access to many of Visual Studio .NET's commands and capabilities. The most commonly used menu commands are duplicated with toolbar buttons for ease of use.

The menus and toolbars are context sensitivei.e., the available selection depends on what part of the IDE is currently selected and what activities are expected or allowed. For example, if the current active window is a code-editing window, the top-level menu commands are:

  • File
  • Edit
  • View
  • Project
  • Build
  • Debug
  • Tools
  • Window
  • Help

If the current window is a design window, then the Data and Format menu commands also become available.

The following sections will describe some of the menu items and their submenus, focusing on the aspects that are interesting and different from common Windows commands. File menu

The File menu provides access to a number of file, project, and solution-related commands. Many of these commands are content sensitive. Below are descriptions of those commands that are not self-explanatory.


As in most Windows applications, the New menu item creates new items to be worked on by the application. In Visual Studio .NET, the New menu item has three submenu items to handle the different possibilities:


The Project command brings up the New Project dialog, which is context sensitive. If no project is currently open, as is sometimes the case when Visual Studio .NET is just opened, you will see the dialog box shown in Figure 3-2.

If there is already a project open, then you will get the New Project dialog box shown in Figure 3-5. This dialog box adds radio buttons to give you the choice of adding the new project to the solution or closing the existing solution and creating a new one to hold the new project.

Figure 3-5. New Project dialog box from menu


File...(Ctrl+ N)

The File command brings up a New File dialog box, as shown in Figure 3-6. It offers three different categories of files and many different types of files (templates) within each category. Files created this way are located by default in the project directory (although you can browse for a different location). They are displayed in the Solution Explorer if the Show All button is toggled, but are not actually part of the solution unless explicitly added using one of the Add menu items described below. In other words, they are the miscellaneous files described above in the section on Solutions.

Figure 3-6. New File dialog box


Blank Solution...

The Blank Solution command also brings up a New Project dialog similar to that shown in Figure 3-5, with the Add to Solution radio button grayed out, the default Project Type set to Visual Studio Solutions, and the Template set to Blank Solution. When a blank solution is created, it contains no items. Add items by using one of the Add menu items described below.

The New command has an equivalent button in the Standard Toolbar that exposes the New Project and Blank Solution commands.


The Open menu item opens pre-existing items. It has four submenu items:


Opens a previously existing project. The currently opened solution is closed before the new project is opened.

Project From Web...

An Open Project From Web dialog box is presented, and it accepts a URL pointing to the project to open. As with Open Project, the currently opened solution is closed before the new project is opened.


Presents a standard Open File dialog box, allowing you to browse to and open any file accessible on your network. Opened files are visible and editable in Visual Studio .NET, but are not part of the project. To make a file part of the project, use one of the Add menu commands described below. The Open File command has an equivalent button on the Standard Toolbar.

File From Web...

An Open File From Web dialog box is presented and accepts a URL pointing to the file to open. As with Open File, the selected file is not made part of the project.

Add New Item...(Ctrl+Shift+A)

Add New Item lets you add a new item to the current project. It presents the Add New Item dialog box shown in Figure 3-7. Expanding the nodes in the Categories pane on the left side of the dialog box narrows the list of Templates shown on the right side.

Use this menu item if you want to add new files to your project, including new source code files. For source code, you would typically add a new Class file, which automatically would have the language-specific filename extension.

This command has an equivalent button in the Standard Toolbar. It is also accessible from the context menu in the Solution Explorer.

Figure 3-7. Add New Item dialog box


Add Existing Item...(Shift+Alt+A)

Add Existing Item is very similar to the Add New Item menu item just described, except that it adds already existing items to the current project. If the item added resides outside the project directory, a copy is made and placed in the project directory.

This menu option is also available from the Solution Explorer context menus.

Add Project

Add Project has three submenus. The first two, New Project and Existing Project, let you add either a new or pre-existing project to the solution. The third, Existing Project From Web, presents a dialog box that accepts the URL of the project to be added.

Open Solution

Clicking on this menu item brings up the Open Solution dialog box, which allows you to browse for the solution to open. The currently open solution will be closed before the new solution is opened.

Close Solution

This menu item is only available if there a solution is currently open. If this menu item is selected, the currently open solution will be closed.

Advanced Save Options...

Advanced Save Options is a context-sensitive submenu that is only visible when editing in a code window. It presents a dialog box that lets you set the encoding option and line ending character(s) for the file.

Source Control

The Source Control submenu item allows you to interact with your source control program. Edit menu

The Edit menu is fairly standard, containing the typical editing and searching commands. It also has some very interesting capabilities.

Cycle Clipboard Ring (Ctrl+Shift+V)

The Clipboard Ring is like copy and paste on steroids. Copy different selections to the Windows clipboard, using the Edit Cut (Ctrl-X) or Edit Copy (Ctrl-C) commands. Then use Ctrl+Shift+V to cycle through all the selections, allowing you to paste the correct one when it comes around. You can also see the whole clipboard ring in the Toolboxit's one of the panes that is visible when you're editing a text file.

This submenu item is context sensitive and is visible only when editing a code window.

Find and Replace Find in Files (Ctrl+Shift+F)

Find in Files is a very powerful search utility that finds text strings anywhere in a directory or in subdirectories (subfolders). It presents the dialog box shown in Figure 3-8. Checkboxes present several self-explanatory options, including the ability to search using either wildcards or regular expressions.

Figure 3-8. Find in Files dialog box


Regular Expressions

Regular expressions are a language unto themselves, expressly designed for incredibly powerful and sophisticated searches. A full explanation of regular expressions is beyond the scope of this book. For a complete discussion of regular expressions, see the SDK documentation or Mastering Regular Expressions, by Jeffrey E. F. Friedl (O'Reilly).

If you click on the Replace button in the Find in Files dialog box, you will get the Replace in Files dialog box shown in Figure 3-9 and described next.

Find and Replace Replace in Files (Ctrl+Shift+H)

Replace in Files is identical to the Find in Files command, just described, except that it also allows you to replace the target text string with a replacement text string.

Figure 3-9. Replace in Files dialog box


This command is extremely useful for renaming forms, classes, namespaces, and projects. Renaming objects is a very common requirement, and it is wiseyou don't want to be saddled with the default names assigned by Visual Studio .NET.

Renaming should not be difficult, but it can be. Object names are spread throughout a project, often hidden in obscure locations such as solution or project files, and throughout source code files. Although all of these files are text files that can be searched and edited, the task can be tedious and error-prone. The Replace in Files command makes it simple, thorough, and reasonably safe.

Find and Replace Find Symbol (Alt+F12)

Clicking on this submenu item brings up the Find Symbol dialog box shown in Figure 3-10. This allows you to search for symbols such as namespaces, classes, and interfaces, and their members such as properties, methods, events, and variables.

Figure 3-10. Find Symbol dialog box


The search results will be displayed in a window labeled Find Symbol Results. From there, you can move to each location in the code by double-clicking on each result.

Go To...

This submenu item brings up the Go To Line dialog box, which allows you to enter a line number and immediately go to that line. It is context sensitive and visible only when editing a text window.

Insert File As Text...

This submenu item allows you to insert the contents of any file into your source code as though you had typed it in. It is context sensitive and visible only when editing a text window.

A standard file browsing dialog box is presented to search for the file that will be inserted. The default file extension will correspond to the project language, but you can search for any file with any extension.


The Advanced submenu item is context sensitive and visible only when you edit a code window. It has many submenu items, including commands for:

  • Creating or removing tabs in a selection (converting spaces to tabs and vice versa)
  • Forcing selected text to uppercase or lowercase
  • Deleting horizontal whitespace
  • Viewing whitespace (make tabs and space characters visible on the screen)
  • Toggling word wrap
  • Commenting and uncommenting blocks of text
  • Increasing and decreasing line indenting
  • Incremental search (described below)

Incremental search (Ctrl+I)

Incremental search lets you search an editing window by entering the search string character by character. As each character is entered, the cursor moves to the first occurrence of matching text.

To use incremental search in a window, select the menu item or press Ctrl+I. The cursor icon will change to a binocular with an arrow indicating the direction of search. Begin typing the text string you want to search for.

The case sensitivity of an incremental search will come from the previous Find, Replace, Find in Files, or Replace in Files search (described above).

The search will proceed downward and left to right from the current location. To search backward, use Ctrl+Shift+I.

The key combinations listed in Table 3-2 apply to incremental searching:

Table 3-2. Incremental searching

Key combination



Stop the search


Remove a character from the search text


Change the direction of the search


Move to the next occurrence in the file for the current search text


Bookmarks are useful for marking spots in your code and easily navigating from marked spot to marked spot. Table 3-3 lists five bookmark commands, along with their shortcut key combinations.

This menu item appears only when a code window is the current window.

Table 3-3. Bookmark commands


Key Combination


Toggle Bookmark

Ctrl+K, Ctrl+K

Place or remove a bookmark at the current line. When a bookmark is set, a blue rectangular icon will appear in the column along the left edge of the code window.

Next Bookmark

Ctrl+K, Ctrl+N

Move to the next bookmark.

Previous Bookmark

Ctrl+K, Ctrl+P

Move to the previous bookmark.

Clear Bookmark

Ctrl+K, Ctrl+L

Clear all the bookmarks.

Add Task List Shortcut

Ctrl+K, Ctrl+H

Add an entry to the Task List (described below under the View menu item) for the current line. When a task list entry is set, a curved arrow icon will appear in the column along the left edge of the code window.


Visual Studio .NET allows you to outline, or collapse and expand sections of your code, to make it easier to view the overall structure. When a section is collapsed, it appears with a plus sign in a box along the left edge of the code window (figs/icon_collapsedregion.gif). Clicking on the plus sign expands the region.

You can nest the outlined regions so that one section can contain one or more other collapsed sections. Several commands that facilitate outlining are shown in Table 3-4.

Table 3-4. Outlining commands


Key combination


Hide Selection

Ctrl+M, Ctrl+H

Collapses currently selected text. In C# only, this command is visible only when automatic outlining is turned off or the Stop Outlining command is selected.

Toggle Outlining Expansion

Ctrl+M, Ctrl+M

Reverses the current outlining state of the innermost section in which the cursor lies.

Toggle All Outlining

Ctrl+M, Ctrl+L

Sets all sections to the same outlining state. If some sections are expanded and some collapsed, then all become collapsed.

Stop Outlining

Ctrl+M, Ctrl+P

Expands all sections. Removes the outlining symbols from view.

Stop Hiding Current

Ctrl+M, Ctrl+U

Removes outlining information for the currently selected section. In C# only, this command is visible only when automatic outlining is turned off or the Stop Outlining command is selected.

Collapse to Definitions

Ctrl+M, Ctrl+O

Automatically creates sections for each procedure in the code window and collapses them all.

Start Automatic Outlining


Restarts automatic outlining after it is stopped.

Collapse Block


In C++ only. Similar to Collapse to Definitions, except it applies only to the region of code containing the cursor.

Collapse All In


In C++ only. Same as Collapse Block, except it recursively collapses all logical structures in a function in a single step.

The default behavior of Outlining can be set using the Tools Options menu item. Go to Text Editor, then indicate the specific language for which you wish to set the options. The outlining options can be set for VB.NET under Basic VB Specific, for C# under C# Formatting, and for C++ under C/C++ Formatting.


Microsoft IntelliSense technology makes programmers' lives much easier. It has real-time, context-sensitive help available that appears right under your cursor. Code completion automatically completes your thoughts for you, drastically reducing your need to type. Drop-down-lists provide all methods and properties possible in the current context, and are available at a keystroke or mouseclick.

What's not to love? IntelliSense makes up for a lot of Visual Studio .NET's more, shall we say, exasperating traits.

The default IntelliSense features can be configured by going to Tools Options, and then the language-specific pages under Text Editor.

Most IntelliSense features appear as you type inside a code window, or allow the mouse to hover over a portion of the code. In addition, the Edit IntelliSense menu item offers the commands shown in Table 3-5.

Table 3-5. IntelliSense commands


Key combination


List Members


Displays a list of all possible members available for the current context. Keystrokes incrementally search the list. Press any key to insert the highlighted selection into your code; that key becomes the next character after the inserted name. Use the Tab key to select without entering any additional characters.

This command can also be accessed by right-clicking and selecting List Member from the context-sensitive menu.

Parameter Info


Displays a list of number, names, and types of parameters required for a method, sub, function, or attribute.

Quick Info

Ctrl+K, Ctrl+I

Displays the complete declaration for any identifier, e.g., variable name or class name, in your code. It is also enabled by hovering the mouse cursor over any identifier.

Complete Word

Alt+Right ArroworCtrl+Space

Automatically completes the typing of any identifier once you type in enough characters to uniquely identify it. This only works if the identifier is entered in a valid location in the code.

The member list presents itself when you type the dot following any class or member name.

Every member of the class is listed, and each member's type is indicated by an icon. You can find icons for methods, fields, properties, events and so forth. In addition, each icon may have a second icon overlaid to indicate the accessibility of the member: public, private, protected, and so on. If there is no accessibility icon, then the member is public.

If the member list does not appear, you should ensure that you have added all the necessary using (or imports) statements. Also remember that IntelliSense is case-sensitive in C#. Also, sometimes C# needs a rebuild before it will reflect the most recent changes.

Table 3-6 lists all the different icons used in the member lists and other windows throughout the IDE. Table 3-7 lists the accessibility icons.

Table 3-6. Object icons


Member type










Enum item
















Map item


Method or function


















Unknown or error


Variable or field

Table 3-7. Object accessibility icons












Protected View menu

The View menu is a context-sensitive menu that provides access to the myriad windows available in the Visual Studio .NET IDE. You will probably keep many of these windows open all the time; you will use others rarely, if at all.

The View menu is context sensitive. For example, if your form has no controls on it, the Tab Order submenu will be grayed out.

When the application is running, a number of other windows become visible or available. These windows are accessed via the Debug Windows menu item, not from the View menu item.

Visual Studio .NET can store several different window layouts. In particular, it remembers a completely different set of open windows during debug sessions than it does during normal editing. These layouts are stored per-user and not per-project or per-solution.

This section covers the areas that may not be self-explanatory.

Open/Open With...

This menu item lets you open the current itemi.e., the item currently selected in the Solution Explorer (described below) 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 Windows 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, as well as all the files, folders, and items contained within them, hierarchically and visibly. 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. Figure 3-11 shows a typical Solution Explorer.

Figure 3-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 or may not appear, depending on the currently selected item in the Solution Explorer). Table 3-8 details the purpose of each button.

Table 3-8. Solution Explorer buttons



Shortcut keys



View Code


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.




Refreshes the Solution Explorer display.


Show All Files


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 3-9 will look like Figure 3-12 after several of the nodes are expanded.




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 3-12. Solution Explorer (expanded)


You can also display miscellaneous files in the Solution Explorer. To do so, go to Tools Options... and then 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 than in the menus. Right-clicking on any item in the Solution Explorer pops up a context-sensitive menu. Three different pop-up menus from Solution Explorer are shown in Figure 3-13. From left to right, they are for a solution, a project, and a source-code file.

Figure 3-13. Solution Explorer context-sensitive menus


Several points bear mention:

  • The Add pop-up menu item for solutions and projects offers submenus that allow new or existing items to be added. This item replicates items contained under the main Project menu.

    Set Startup Projects and Exclude From Project are also replicated under the main Project menu.

  • The Build and Rebuild pop-up menu items replicate items contained under the main Build menu.
  • The Debug pop-up menu item replicates two items from 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 Properties page for that item is 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 entry in the window. The property values on the right side of the window are editable.

One possible source of confusion 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.

Figure 3-14 shows a typical Properties window with the Font subproperty expanded out.

Figure 3-14. Properties window


The name and type of the current object is displayed in the field at the top of the window. In Figure 3-14, it is an object named Button1 of type Button, contained in the System.Windows.Forms namespace.

The Font property has subproperties that may be set either directly in the window or by clicking on the button with three dots on it, which brings up a standard font dialog box. Other properties with subproperties may or may not have a dialog box associated with them, as need be. Other properties, such as the Font Name property, may have drop-downs in the property grid itself.

The property 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 right-most button displays property pages for the object, if there are any.

Some objects have both a Properties window and Properties pages. The Property pages display additional properties from those shown in the Properties window.

If the project is in C#, then an additional lightning bolt button is used to create event handlers for an item. Events are covered in Chapter 4.

For some controls, such as TabControl, an additional panel is part of the Properties window with verbs, such as Add Tab and Remove Tab.

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, and access message queues and performance counters. You can also drag nodes from the Server Explorer onto Visual Studio .NET projects, creating components that reference the data source.

Figure 3-15 shows a typical Server Explorer. It is a hierarchical view of the available servers. In this figure, only one server is available, ATH13T. The figure shows a drill-down into SQL Server, with the tables in the Northwind database. These tables, and all other objects in this tree view, are directly accessible and editable from the window.

Figure 3-15. Server Explorer


Class View (Ctrl+Shift+C)

The Class View shows all the classes in the solution hierarchically. A typical Class View, somewhat expanded, is shown in Figure 3-16. The icons used in this window are listed in Table 3-6 and Table 3-7.

As with the Solution Explorer, any item in the class view can be right-clicked, which exposes a pop-up menu with context-sensitive menu items. This provides 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.

Figure 3-16. Class View


The button on the left above the class list lets you sort the listed classes, 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 listed classes. These folders are saved as part of the solution in the .suo file.

These folders are virtual (i.e., they are illusory). They are used only for viewing the list, and 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. 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. Figure 3-17 shows a typical Object Browser window.

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 3-6 and Table 3-7.

Right-clicking on either an object or a member brings up a context-sensitive pop-up menu with a variety of menu options.

Figure 3-17. Object Browser


Other Windows

Several other windows have been relegated to a submenu called Other Windows:

Macro Explorer (Alt+F8)

Visual Studio .NET offers the ability to automate repetitive chores with macros. A macro is a set of instructions written in VB.NET, either created manually or recorded by the IDE, saved in a file. The Macro Explorer is one of the main tools for viewing, managing, and executing macros. It provides access into the Macro IDE.

Macros are described further in the section below on the Tools Macro menu command.

Document Outline (Ctrl+Alt+T)

When you design Web Forms, the Document Outline window is used to provide an outline view of the HTML document.

Task List (Ctrl+Alt+K)

In large applications, keeping a to-do list can be quite helpful. Visual Studio .NET provides this functionality with the Task List window. You can also provide shortcuts to comments in the Task List along with token strings, such as TODO, HACK, or UNDONE. The compiler also populates the Task List with compile errors.

Command Window (Ctrl+Alt+A)

The Command window has two modes: Command and Immediate.

Command mode enters commands directly, either bypassing the menu system or executing commands that are not contained in the menu system. (You can add any command to the menu or a toolbar button by using Tools Customize.)

Immediate mode is used when debugging to evaluate expressions, view and modify variables, and other debugging tasks. The Immediate window and debugging will be covered further in Chapter 21.

For a complete discussion of command window usage, consult the SDK documentation.

Output (Ctrl+Alt+O)

The Output window displays status messages from the IDE to the developer, including debugger messages, compiler messages, and output from stored procedures. Project menu

The Project menu provides functionality related to project management. All functionality exposed by the Project menu is available in the Solution Explorer. It is often easier and more intuitive to accomplish your goals in Solution Explorer, but the menus lend themselves to keyboard use.

Each command under this menu pertains to the object currently highlighted in the Solution Explorer.

Add... Menu Items

Several menu items allow you to add either an existing or a new item to a project. They are self-explanatory, offering the same functionality as the equivalent items described previously under the File command.

They include:

Add Windows Form

Add Inherited Form

Add User Control

Add Inherited Control

Add Component

Add Class

Add New Item (Ctrl+Shift+A)

Add Existing Item (Shift+Alt+A)

Exclude From Project

Exclude From Project removes the file from the project but leaves the file intact on the hard drive. This is in contrast with the Delete popup menu item in the Solution Explorer. That will remove the file from the project and delete it from the hard drive (actually into the Recycle Bin). If a resource file is associated with the file, it will also be excluded or deleted, respectively.

The Exclude From Project command is also made available in the Solution Explorer by right-clicking on a file.

Add Reference...

The Add Reference command is available in the Solution Explorer by right-clicking on a project. In either case, you will get the Add Reference dialog box shown in Figure 3-18. This dialog box allows you to reference assemblies or DLL's external to your application, making the public classes, methods, and members contained in the referenced resource available to your application.

Figure 3-18. Add Reference dialog box


Add Web Reference...

The Add Web Reference command, also available in the Solution Explorer by right-clicking a project, allows you to add a web reference to your project, thereby becoming a consuming web service application.

Web services are covered in Programming ASP.NET, Second Edition, by Jesse Liberty and Dan Hurwitz (O'Reilly).


Set as StartUp Project

If there is more than one project in a solution, specify the startup project. This command, also available in the Solution Explorer by right-clicking a project, allows you to make that specification. The project highlighted in Solution Explorer when this command is executed will become the startup project.

Project Dependencies... / Project Build Order...

These commands, visible only when a solution contains multiple projects, also available in the Solution Explorer by right-clicking a project, presents a dialog box that allows you to control the build order of the projects in a solution. It presents a dialog box with two tabs: one for Dependencies and one for the Build Order.

The Project Dependencies command allows you to specify, for each project in the solution, which projects it depends upon. The dependent projects will be built first.

The Project Build Order command presents a list of all projects in the order in which they will be built.

If you are using Project References (as added with the Add Reference dialog mentioned above), you won't be able to edit either command. Project Dependencies are inferred when there are references between projects in the same solution. Also, you can't change the Build Order in any caseit is always inferred from the dependencies, whether or not those dependencies were automatically inferred. Build menu

The Build menu offers menu items for building the current project (highlighted in Solution Explorer) or the solution. It also exposes the Configuration Manager for configuring the build process.

The Build menu will be covered in detail in Chapter 22, which discusses deployment and configuration. Debug menu

The Debug menu allows you to start an application with or without debugging, set breakpoints in the code, and control the debugging session.

The Debug menu item will be covered, along with debugging, in Chapter 21. Data menu

This context-sensitive menu is visible only in the design mode. It is not available when editing code pages. The commands under it are available only when there are appropriate data controls on the form.

Chapters 19 through 21 cover data controls and data binding. Format menu

The Format menu is visible only when in design mode, and the commands under it are available only when one or more controls on the form are selected.

This menu offers the ability to control the size and layout of controls. You can:

  • Align controls with a grid or with other controls six different ways
  • Change the size of one or more controls to be bigger or smaller (or all be the same)
  • Control the spacing horizontally and vertically
  • Move controls forward or back in the vertical plane (z-order) of the form
  • Lock a control so its size or position cannot be changed

To operate on more than one control, select the controls in one of several ways:

  • Hold down Shift or Ctrl while clicking on controls you wish to select.
  • Use the mouse to click and drag a selection box around all the controls to be selected. If any part of a control falls within the selection box, then that control will be included.
  • To unselect one control, hold down Shift or Ctrl while clicking that control.
  • To unselect all the controls, select a different control or press Esc.

When operating on more than one control, the last selected control will be the baseline. In other words, if you are making all the controls the same size, they will all become the same size as the last selected control. Likewise, if aligning a group of controls, they will all align with the last selected control.

As controls are selected, they will display eight resizing handles. These resizing handles will be white for all the selected controls except the baseline, or last control, which will have black handles.

With that in mind, all the commands under the Format menu are fairly self-explanatory. Tools menu

The Tools menu presents commands that access a wide range of functionality, ranging from connecting to databases, to accessing external tools, to setting IDE options. Some of the most useful commands are described next.

Connect to Device...

The Connect to Device command brings up a dialog box that allows you to connect to either a physical mobile device or an emulator.

Connect to Database...

The Connect To Database command brings up the dialog box that allows you to select a server, log in to that server, and connect to the database on the server. Microsoft SQL Server is the default database (surprise!), but the Provider tab lets you connect to any number of other databases, including any for which there are Oracle, ODBC, or OLE DB providers.

Connect to Server...

The Connect to Server command brings up the dialog box that lets you specify a server to connect to, either by name or by IP address. It also lets you connect by using a different username and password.

This same dialog box can be exposed by right-clicking on Servers in the Server Explorer and selecting Add Server... from the pop-up menu.

Add/Remove Toolbox Items...

The Add/Remove Toolbox Items command brings up the Customize Toolbox dialog box shown in Figure 3-19. The dialog box has two tabs: one for adding (legacy) COM components and one for adding .NET CLR-compliant components. All the components available on your machine (including registered COM components and .NET components in specific directories; you can browse for .NET components if they are not listed) are listed in one or the other. In either case, check or uncheck the line in front of the component to include the desired component.

For adding .NET components to the Toolbox, just drag it from Windows Explorer onto the Toolbox.

It is also possible to add other tabbed lists to this dialog box, although the details for doing so are beyond the scope of this book.

You can sort the components listed in the dialog box by clicking on the column head by which you wish to sort.

Figure 3-19. Customize Toolbox dialog box


Build Comment Web Pages...

This menu command brings up a dialog box that allows you to document your application via HTML pages. These HTML pages automatically display the code structure of your application. Projects are listed as hyperlinks. Clicking on a project brings up a page that shows all the classes as hyperlinks on the left side of the page. Clicking on any class lists all the class members, with descriptions, on the right side of the page.

If your language supports XML code comments (as does C#, but VB.NET does not), then you can add your own comments to your source code, and those comments will display in these web pages.

Comment web pages are created by default in a subdirectory of the project called CodeCommentReport.


Macros are a wonderful feature that allows you to automate tasks in the IDE. Macros can either be coded by hand or recorded as you perform the desired task. If you allow the IDE to record the macro for you, then you can subsequently examine and edit the macro code it creates. This is similar to the macro functionality provided as part of Microsoft Word or Excel.

Be aware that macro recording doesn't work for anything inside a dialog box. For example, if you record the changing of property in a project's Property Pages, the recorded macro will open the Property Pages but won't do anything in there!

You can easily record a temporary macro by using the Macros Record TemporaryMacro command, or by pressing Ctrl+Shift+R. This temporary macro can then be played back using the Macros Run TemporaryMacro command, or by pressing Ctrl+Shift+P. It can be saved using the Macros Save TemporaryMacro command, which will automatically bring up the Macro Explorer, described next.

Macros are managed with a Macro Explorer window, accessed via a submenu of the Macros command, or by pressing Alt+F8, as shown in Figure 3-20 after recording a temporary macro.

Figure 3-20. Macro Explorer


Right-clicking on a macro in the Macro Explorer pops up a menu with four items:


Runs the highlighted macro. The macro can also be run by double-clicking on the macro name.


Brings up the macro editing IDE, where all macros for the user can be edited. The macro language is VB.NET, irrespective of the language used for the project. The macro editing IDE can also be invoked using the Macros Macro IDE command, or by pressing Alt+F11.


Allows the macro to be renamed.


Deletes the macro from the macro file.

All macros are contained in a macro project called, by default, MyMacros. This project is comprised of a binary file called MyMacros.vsmacros (unless you have elected to convert it to the multiple files format), which is physically located in the Documents and Settings directory for each user. You can create a new macro project by using the Macros New Macro Project command or by right-clicking on the root object in the Macro Explorer and selecting New Macro Project. In either case, you will get the New Macro Project dialog box, which lets you specify the name and location of the new macro project file.

Macro projects contain modules, which are units of code. Each module contains subroutines, which correspond to the macros. For example, the macro called TemporaryMacro, shown in Figure 3-20 is the TemporaryMacros subroutine contained in the module named RecordingModule, which is part of the MyMacros project.

External Tools...

Depending on the options selected at the time Visual Studio .NET was installed on your machine, you may have one or more external tools available on the Tools menu. The tools might include Create GUID, ATL/MFC Trace Tool, or Spy++. (Use of these tools is beyond the scope of this book.)

The Tools External Tools... command allows you to add additional external tools to the Tools menu. When selected, you are presented with the External Tools dialog box. This dialog box has fields for the tool title, the command to execute the tool, any arguments and the initial directory, as well as several checkboxes for different behaviors.


The Customize... command allows you to customize many aspects of the IDE user interface. (The Options... command, described in the following section, lets you set a variety of other program options.) It brings up the Customize dialog box, which has three different tabs, plus one additional button, allowing customization in four different areas.


This tab, shown in Figure 3-21, presents a checkbox list of all available toolbars, with checkmarks indicating currently visible toolbars. You can control the visibility of specific toolbars by checking or unchecking them in this list, or alternatively, use the View Toolbars command.

You can also create new toolbars, rename or delete existing toolbars, or reset all the toolbars back to the original installation version on this tab.

Figure 3-21. Customize dialog (Toolbars tab)



The Commands tab, shown in Figure 3-22, allows you to add or remove commands from a toolbar or modify buttons already on the toolbar.

To add a command to a toolbar, select the category and command from the lists in the dialog box, and then use the mouse to drag the command to the desired toolbar.

To remove a command from a toolbar, drag it from the toolbar to anywhere in the IDE while the Customize Commands dialog is showing.

The Modify Selection button is active only when a button on an existing toolbar is selected. It allows you to perform such chores as renaming or deleting the button, changing the image displayed on the button, changing the display style of the button (image only, text only, etc.), and organizing buttons into groups.

Figure 3-22. Customize dialog (Commands tab)



The Options tab, shown in Figure 3-23, allows you to change the toolbar's appearance.

The personalized Menus and Toolbars checkboxes are always unavailable and grayed out.

The Other checkboxes allow selection of icon size on buttons, control of tool tips, and the way the menus come in to view (Menu animations).

Figure 3-23. Customize dialog (Options tab)



The Keyboard... button brings up the Environment Keyboard page, shown in Figure 3-24, also accessible under the Tools Options command described below. This page allows you to define and change keyboard shortcuts for commands.

Figure 3-24. Customize dialog (Keyboard button)



The Options... command brings up the Options dialog box, shown in Figure 3-24. This dialog box lets you set a wide range of options, ranging from the number of items to display in lists of recently used items, to XML Designer options.

The dialog box displays a hierarchical list of categories on the left side. Selecting any category allows you to drill down through the tree structure. Clicking on a detail item brings up the available properties on the right side of the dialog box.

Most available options are fairly self-explanatory. If you have any questions about specific settings, clicking on the Help button at the bottom of the Options dialog box will bring up context-sensitive help about all the properties relevant to the current detail item. Window menu

The Window menu item is a fairly standard Windows application Window command. It displays a list of the currently open windows, allowing you to bring any window to the fore by clicking on it. All the file windows currently displayed in the IDE also have tabs along the top edge of the design window, below the toolbars (unless you selected MDI mode in Tools Options Environment General), and windows can be selected by clicking on a tab.

This is a context-sensitive menu. Table 3-9 lists the menu items available for different circumstances.

Table 3-9. Window menu item commands

Current window

Description of available commands


Auto Hide All hides all dockable windows. Clicking on window's pushpin icon turns AutoHide off for that window.

New Horizontal/Vertical Tab Group creates another set of windows with it own set of tabs.

Close All Documents is self-explanatory.

Window list.


Same as for a design window plus the following:

New Window creates a new window containing the same file as the current window. Use it to open two windows to the same source file.

Split creates a second window in the current window for two different views of the same file.

Remove Split removes a split window.


This category includes the Solution Explorer, the Properties window, the Class View window, the Toolboxes, etc. These windows are dockable, as indicated by the pushpin icon in the upper-right corner of each.

Available menu items are the same as for a design window, with the addition of commands to dock, hide, or float a window. Help menu

The Help menu provides access to a number of submenus. Those that are not self-explanatory are described here.

Dynamic Help (Ctrl+F1)

If you are developing on a machine with enough horsepower, Dynamic Help is wonderful. Otherwise, it is a performance hog. (It can be disabled by unchecking all the checkboxes under Tools Options Environment Dynamic Help) Alternatively, just closing the window is sufficient to prevent the performance hit, and then it is still available when you need it.

That said, using Dynamic Help is very simple. Open a Dynamic Help window by clicking on this menu item or pressing Ctrl+F1. Then wherever the focus is, whether in a design, code, or dockable window, context-sensitive hyperlinks will appear in the Dynamic Help window. Click on any link to bring up the relevant Help topic in a separate window.

Contents... (Ctrl+Alt+F1)/Index... (Ctrl+Alt+F2)/Search... (Ctrl+Alt+F3)

These three commands provide different views into the SDK help system, allowing you to search by a (pseudo) table of contents, an incremental index, or a search phrase, respectively. The first type of search is an indexed search, while the latter two are full-text searches, so you may get different results by using the different search types using the same phrase.

The Help system exposed by these commands is the same Help system exposed in two other places by the Start button:

  • Programs Microsoft Visual Studio .NET 2003 Microsoft Visual Studio .NET 2003 Documentation
  • Programs Microsoft .NET Framework SDK v1.1 Documentation

This Help tool uses a browser-type interface, with Forward and Back navigation and Favorites. The list of topics is displayed in the lefthand pane, and the help topic itself, including hyperlinks, is displayed on the right.

Index Results... (Shift+Alt+F2)

When searching for Help topics by Index, you will often find many topics for a given index entry. In these cases, the multiple topics are listed in an Index Results window. This window displays automatically if this is the case. This command lets you view the Index Results window if it has been closed.

Search Results... (Shift+Alt+F3)

The Search Results window is analogous to the Index Results window described previously, except it pertains to searching for Help topics by search phrase.

Edit Filters...

The SDK Help system is voluminous, with information on the full array of topics that might be found in any .NET installation, as well as a ton of non-.NET stuff as well. The Edit Filters command lets you restrict which Help topics will be searched. For example, if you are working exclusively in C#, you might set the filter to either Visual C# or Visual C# and Related.

Check for Updates

This command checks for service releases for your currently installed version of Visual Studio .NET. For this command to work, your machine must be connected to the Internet. If an update is available, you will be prompted to close the IDE before the service release is installed.

Windows Forms and the .NET Framework

Getting Started

Visual Studio .NET


Windows Forms

Dialog Boxes

Controls: The Base Class

Mouse Interaction

Text and Fonts

Drawing and GDI+

Labels and Buttons

Text Controls

Other Basic Controls

TreeView and ListView

List Controls

Date and Time Controls

Custom Controls

Menus and Bars


Updating ADO.NET

Exceptions and Debugging

Configuration and Deployment

show all menu

Programming. NET Windows Applications
Programming .Net Windows Applications
ISBN: 0596003218
EAN: 2147483647
Year: 2003
Pages: 148
Similar book on Amazon © 2008-2017.
If you may any questions please contact us: