Chapter 2. Menus, Toolbars, and Windows

The Visual Studio IDE is incredibly powerful and provides hundreds of tools for building and modifying projects. The price you pay for all of these powerful tools is extra complexity. Because so many tools are available, it can take some digging to find the tool you want, even if you know exactly what you need.

This chapter describes the menus, toolbars, and windows that contain the tools provided by the IDE. It explains some of the most useful tools provided by the IDE and tells where to find them, provided you haven't moved them while customizing the IDE.

This chapter also tells how you can customize the menus and toolbars to give you easy access to the commands that you use most frequently and how to hide those that you don't need.

MENUS

The IDE's menus contain standard Visual Studio commands. These are generally commands that manipulate the project and the modules it contains. Some of the concepts are similar to those used by any Windows application (File

MENUS

The menus are customizable, so you can add, remove, and rearrange the menus and the items they contain. This can be quite confusing, however, if you later need to find a command that you have removed from its normal place in the menus. Some developers place extra commands in standard menus, particularly the Tools menu, but it is generally risky to remove standard menu items. Usually it is safest to leave the standard menus alone and make custom menus and toolbars to hold customizations. For more information on this, see Chapter 3, "Customization."

Many of the menus' most useful commands are also available in other ways. Many provide keyboard shortcuts that make using them quick and easy. For example, Ctrl+N opens the New Project dialog box just as if you had selected the File

MENUS

Many menu commands are also available in standard toolbars. For example, the Debug toolbar contains many of the same commands that are in the Debug menu. If you use a set of menu commands frequently, you may want to display the corresponding toolbar to make using the commands easier.

Visual Studio also provides many commands through context menus. For example, if you right-click a project in the Solution Explorer, the context menu includes an Add Reference command that displays the Add Reference dialog box just as if you had invoked Project

MENUS

The following sections describe the general layout of the standard menus and briefly explain their most important commands. You might want to open the menus in Visual Studio as you read these sections, so you can follow along.

File

The File menu contains commands that deal with creating, opening, saving, and closing projects and project files. The following list describes the most important commands contained in the File menu and its submenus:

  • New Project — This command displays the dialog box shown in Figure 2-1. This dialog box lets you create new Windows applications, class libraries, console applications, control libraries, and more. Select the type of project yo want to start, enter a project name, and click OK.

    The New Project dialog box lets you start various kinds of new projects.

    Figure 2.1. The New Project dialog box lets you start various kinds of new projects.

  • New Web Site — This command lets you start a new web site project. It displays a dialog box where you can select the type of web site to create from among choices such as ASP.NET Web Site, ASP.NET Web Service, and Empty Web Site.

  • Open Project — This command lets you open an existing project.

  • Open Web Site — This command lets you open an existing web site project.

  • Open File — This command displays the dialog box shown in Figure 2-2 and lets you select a file to open. The IDE uses integrated editors to let you edit the new file. For example, a simple bitmap editor lets you set a bitmap's size, change its number of colors, and draw on it. When you close the file, Visual Studio asks if you want to save it. Note that this doesn't automatically add the file to your current project. You can save the file and use the Project

    The New Project dialog box lets you start various kinds of new projects.
    The Open File dialog box lets you select files to view and edit.

    Figure 2.2. The Open File dialog box lets you select files to view and edit.

  • Add — This submenu lets you add new items to the current solution. This submenu's most useful commands for Visual Basic developers are New Project and Existing Project, which add a new or existing Visual Basic project to the current solution.

  • Close — This command closes the current editor. For example, if you were editing a form in the Windows Forms Designer, this command closes the Designer.

  • Close Project — This command closes the entire project and all of the files it contains. If you have a solution open, this command is labeled Close Solution and it closes the entire solution.

  • Save Form1.vb — This command saves the currently open file, in this example, Form1.vb.

  • Save Form1.vb As — This command lets you save the currently open file in a new file.

  • Save All — This command saves all modified files. When you start a new project, the files are initially stored in a temporary location. This command allows you to pick a directory where the project should be saved permanently.

  • Export Template — The Export Template command displays the dialog box shown in Figure 2-3. The Export Template Wizard enables you to create project or item templates that you can use later when making a new project.

    The File/Export Template command displays this dialog box to help you create project or items templates that you can easily use in other projects.

    Figure 2.3. The File/Export Template command displays this dialog box to help you create project or items templates that you can easily use in other projects.

  • Page Setup and Print — The Page Setup and Print commands let you configure printer settings and print the current document. These commands are enabled only when it makes sense to print the current file. For example, they let you print if you have a code editor open because the code is text but they are disabled while you are using a Windows Forms Designer.

  • Recent Files and Recent Projects and Solutions — The Recent Files and Recent Projects and Solutions submenus let you quickly reopen files, projects, and solutions that you have used recently.

Edit

The Edit menu contains commands that deal with manipulating text and other objects. These include standard commands such as the Undo, Redo, Cut, Copy, Paste, and Delete commands that you've seen in other Windows applications.

The following list describes other important commands contained in the Edit menu:

  • Find Symbol — The Find Symbol command lets you search the application for a program symbol rather than a simple string. You can search for such items as namespaces, types, interfaces, properties, methods, constants, and variables.

  • Quick Find — This command displays a find dialog box where you can search the project for specific text. A drop-down menu lets you indicate whether the search should include the current document, the currently selected text, all open documents, the current project, or the current solution. Options let you determine such things as whether the text must match case or whole words.

  • Quick Replace — This command displays the same dialog box as the Quick Find command except with some extra controls. It includes a text box where you can specify replacement text, and buttons that let you replace the currently found text or all occurrences of the text.

  • Go To — This command lets you jump to a particular line number in the current file.

  • Insert File As Text — This command lets you select a file and insert its text into the current location. This can be useful if the file contains a code snippet.

  • Advanced — The Advanced submenu contains commands for performing more complex document formatting such as converting text to upper-or lowercase, controlling word wrap, and commenting and uncommenting code.

  • Bookmarks — The Bookmarks submenu lets you add, remove, and clear bookmarks, and move to the next or previous bookmark. You can use bookmarks to move quickly to specific pieces of code that you have previously marked.

  • Outlining — The Outlining submenu lets you expand or collapse sections of code, and turn outlining on and off. Collapsing code that you are not currently editing can make the rest of the code easier to read.

  • IntelliSense — The IntelliSense submenu gives access to IntelliSense features. For example, its List Members command makes IntelliSense display the current object's properties, methods, and events.

  • Next Method/Previous Method — The Next Method and Previous Method commands move to the next or previous method or class in the current document.

View

The View menu contains commands that let you hide or display different windows and toolbars in the Visual Studio IDE. The following list describes the View menu's most useful commands:

  • Code — The Code command opens the selected file in a code editor window. For example, to edit a form's code, you can click the form in the Solution Explorer and then select View

    View
  • Designer — The Designer command opens the selected file in a graphical editor if one is defined for that type of file. For example, if the file is a form, this command opens the form in a graphical form editor. If the file is a class or a code module, the View menu hides this command because Visual Studio doesn't have a graphical editor for those file types.

  • Standard windows — The next several commands in this menu list some explorers, Object Browser, Error List, Properties window, and Toolbox. These commands restore a previously hidden window.

  • Other Windows — The Other Windows submenu lists other standard menus that are not listed in the View menu itself. These include the Bookmark window, Class View, Command window, Document Outline, Output, Task List, Macro Explorer, and many others. Like the standard windows commands, these commands are useful for recovering lost or hidden windows.

  • Tab Order — If the currently visible document is a Windows Form that contains controls, the Tab Order command displays the tab order on top of each control. You can click the controls in the order you want them to have to set their tab orders quickly and easily. (If you are working with a WPF form, you must set the controls' TabIndex properties to set their tab order.)

  • Toolbars — The Toolbars submenu lets you hide or display the currently defined toolbars. This submenu lists the standard toolbars in addition to any custom toolbars you have created.

  • Full Screen — The Full Screen command hides all toolbars and windows except for any editor windows that you currently have open. It also hides the Windows taskbar so that the IDE occupies as much space as possible. This gives you the most space possible for working with the files you have open. The command adds a small box to the title bar containing a Full Screen button that you can click to end full-screen mode.

  • Property Pages — This command displays the current item's property pages. For example, if you select an application in the Solution Explorer, this command displays the application's property pages similar to those shown in Figure 2-4.

    The View menu's Property Pages command displays an application's property pages.

    Figure 2.4. The View menu's Property Pages command displays an application's property pages.

Project

The Project menu contains commands that let you add and remove items to and from the project. Which commands are available depends on the currently selected item.

The following list describes the most important commands on the Project menu:

  • New items — The first several commands let you add new items to the project. These commands are fairly self-explanatory. For example, the Add Class command adds a new class module to the project. Later chapters explain how to use each of these file types.

  • Add New Item — The Add New Item command displays the dialog shown in Figure 2-5. The dialog lets you select from a wide assortment of items such as about boxes, text files, bitmap files, and class modules.

    The Project menu's Add New Item command lets you add a wide variety of items to the project.

    Figure 2.5. The Project menu's Add New Item command lets you add a wide variety of items to the project.

  • Add Existing Item — The Add Existing Item command lets you browse for a file and add it to the project. This may be a Visual Basic file (such as a module, form, or class), or some other related file (such as a related document or image file).

  • Exclude From Project — This command removes the currently selected item from the project. Note that this does not delete the file; it just removes it from the project.

  • Show All Files — The Show All Files command makes Solution Explorer list files that are normally hidden. These include resource files used by forms, and hidden partial classes such as designer-generated form code. Normally, you don't need to work with these files, so they are hidden. Select this command to show them. Select the command again to hide them again.

  • Add Reference — The Add Reference command displays the dialog shown in Figure 2-6. Select the category of the external object, class, or library that you want to find. For a .NET component, select the .NET tab. This is what you'll want most of the time. For a Component Object Model (COM) component such as an ActiveX library or control built using Visual Basic 6, select the COM tab. Select the Projects tab to add a reference to another Visual Studio project. Click the Browse tab to manually locate the file you want to reference.

    Use the Add Reference dialog box to add references to libraries.

    Figure 2.6. Use the Add Reference dialog box to add references to libraries.

    Scroll through the list of references until you find the one you want and select it. You can use Shift+Click and Ctrl+Click to select more than one library at the same time. When you have made your selections, click OK to add the references to the project. After you have added a reference to the project, your code can refer to the reference's public objects. For example, if the file MyMathLibrary.dll defines a class named MathTools and that class defines a public function Fibonacci, a project with a reference to this DLL could use the following code:

    Dim math_tools As New MyMathLibrary.MathTools
    MessageBox.Show("Fib(5) = " & math_tools.Fibonacci(5))
  • Add Service Reference — The Add Service Reference command displays the dialog shown in Figure 2-7. You can use this dialog to find Web Services and add references to them so your project can invoke them across the Internet. Figure 2-7 shows a service reference for the TerraServer map and aerial photography service. For more information, go to terraserver.microsoft.com.

  • WindowsApplication1 Properties — This command displays the application's property pages shown in Figure 2-4.

Use the Add Service Reference dialog to add references to Web Services.

Figure 2.7. Use the Add Service Reference dialog to add references to Web Services.

Use the tabs on the left of the application's property pages to view and modify different types of application settings. You can leave many of the property values at their default values and many can be set in ways other than the property pages. For example, by default, the Assembly name and Root namespace values shown in Figure 2-4 are set to the name of the project when you first create it. For more projects, that's fine.

Figure 2-8 shows the Compile property page. This page holds four properties that deserve special mention.

The Compile tab contains important properties for controlling code generation.

Figure 2.8. The Compile tab contains important properties for controlling code generation.

First, Option Explicit determines whether Visual Basic requires you to declare all variables before using them. Leaving this option turned off can sometimes lead to subtle bugs. For example, the following code is intended to print a list of even numbers between 0 and 10. Unfortunately, a typographical error makes the Debug.WriteLine statement print the value of the variable j not i. Because j is never initialized, the code prints out a bunch of blank values. If you set Option Explicit to On, the compiler complains that the variable j is not declared and the problem is easy to fix.

For i = 1 To 10
    If i Mod 2 = 0 Then Debug.WriteLine(j)
Next i

The second compiler option is Option Strict. When this option is turned off, Visual Studio allows your code to implicitly convert from one data type to another, even if the types are not always compatible. For example, Visual Basic will allow the following code to try to copy the string s into the integer i. If the value in the string happens to be a number, as in the first case, this works. If the string is not a number, as in the second case, this fails at runtime.

Dim i As Integer
Dim s As String
s = "10"
i = s ' This works.
s = "Hello"
i = s ' This Fails.

If you set Option Strict to On, the IDE warns you at compile time that the two data types are incompatible, so you can easily resolve the problem while you are writing the code. You can still use conversion functions such as CInt, Int, and Integer.Parse to convert a string into an Integer, but you must take explicit action to do so. This makes you think about the code and reduces the chances that the conversion is just an accident. This also helps you use the correct data types and avoid unnecessary conversions that may make your program slower.

The third compiler directive, Option Compare, can take the values Binary or Text. If you set Option Compare to Binary, Visual Basic compares strings using their binary representations. If you set Option Compare to Text, Visual Basic compares strings using a case-insensitive method that depends on your computer's localization settings. Option Compare Binary is faster, but may not always produce the result you want.

The final compiler directive, Option Infer, determines whether you can omit the data type when declaring a variable and let Visual Basic deduce its data type from the context. For example, the first statement in the following code declares the variable x, explicitly declaring it as a Single. The second statement declares variable y without specifying a data type. Because y's initialization value looks like a Double, Visual Basic infers that the variable should be a Double.

Dim x As Single
Dim y = 3.14159265

The problem with inferred data types is that it is not obvious from the code what data type Visual Basic should use. In the preceding code, you need to know Visual Basic's inference rules to know whether variable y is a Single, Double, or Decimal.

You can use an Option statement to set the values for each of these options at the top of a code module. For example, the following code turns Option Explicit On and Option Infer Off for a module:

Option Explicit On
Option Infer Off

Instead of using Option statements in a file, you can use the property page shown in Figure 2-8 to set these options for all of the files in the application.

A final item on this tab that deserves special mention is the "Generate XML documentation file" checkbox near the bottom. If you check this box, then when you build the application Visual Studio creates an XML document containing any XML comments you have included in the code. For more information about XML comments, see the section "XML Comments" in Chapter 14, "Program and Module Structure."

Build

The Build menu contains commands that let you compile projects within a solution. The following list describes the most useful commands contained in the Build menu:

  • Build WindowsApplication1 — This command compiles the currently selected project, in this case the project WindowsApplication1. Visual Studio examines the project's files to see if any have changed since the last time it compiled the project. If any of the files have changed, Visual Studio saves and recompiles them.

  • Rebuild WindowsApplication1 — This command recompiles the currently selected project from scratch. It recompiles every file even if it has not been modified since the last time it was compiled.

  • Clean WindowsApplication1 — This command removes temporary and intermediate files that were created while building the application, leaving only the source files and the final result .exe and .dll files.

  • Publish WindowsApplication1 — This command displays the Publish Wizard shown in Figure 2-9. It can walk you through the process of making your application available for distribution in a local file, file share, FTP site, or web site.

The Publish Wizard helps you deploy an application.

Figure 2.9. The Publish Wizard helps you deploy an application.

If your solution contains more than one application, then the Build menu also contains the solution-related commands Build Solution, Rebuild Solution, and Clean Solution. These are similar to their application counterparts except they apply to every application in the solution.

Debug

The Debug menu contains commands that help you debug a program. These commands help you run the program in the debugger, move through the code, set and clear breakpoints, and generally follow the code's execution to see what it's doing and hopefully what it's doing wrong.

For more information about the Debug menu and debugging Visual Basic code, see Chapter 7, "Debugging."

Data

The Data menu contains commands that deal with data and data sources. Some of the commands in this menu are only visible and enabled if you are designing a form and that form contains the proper data objects.

The following list describes the most useful Data menu commands:

  • Show Data Sources — This command displays the Data Sources window, where you can work with the program's data sources. For example, you can drag and drop tables and fields from this window onto a form to create controls bound to the data source.

  • Preview Data — This command displays a dialog box that lets you load data into a DataSet and view it at design time.

  • Add New Data Source — This command displays the Data Source Configuration Wizard, which walks you through the process of adding a data source to the project.

  • Add Query — This command is available when you are designing a form and have selected a data-bound control such as a DataGridView or bound TextBox. This command opens a dialog where you can specify a query to add to the form. This places a ToolStrip on the form containing ToolStripButtons that populate the bound control by executing the query.

Format

The Format menu contains commands that arrange controls on a form. The commands are grouped into submenus containing related commands. The following list describes the Format menu's submenus:

  • Align — This submenu contains commands that align the controls you have selected in various ways. It contains the commands Lefts, Centers, Rights, Tops, Middles, Bottoms, and to Grid. For example, the Lefts command aligns the controls so their left edges line up nicely. The to Grid command snaps the controls to the nearest grid position.

  • Make Same Size — This submenu contains commands that makes the dimensions of the controls you have selected the same. It contains the commands Width, Height, and Both. The Size to Grid command adjusts the selected controls' widths so that they are a multiple of the alignment grid size. (This command is disabled unless the Windows Forms Designer's LayoutMode is set to SnapToGrid. To set this, open the Tools menu, select the Options command, go to the Windows Forms Designer tab, open the General sub-tab, and set the LayoutMode property.)

  • Horizontal Spacing — This submenu contains commands that change the horizontal spacing between the controls you have selected. It contains the commands Make Equal, Increase, Decrease, and Remove.

  • Vertical Spacing — This submenu contains the same commands as the Horizontal Spacing submenu except it adjusts the controls' vertical spacing.

  • Center in Form — This submenu contains the commands Horizontally and Vertically that center the selected controls on the form either horizontally or vertically.

  • Order — This submenu contains the commands Bring to Front and Send to Back, which move the selected controls to the top or bottom of the stacking order.

  • Lock Controls — This command locks all of the controls on the form so that you cannot move or resize them by clicking and dragging, although you can still move and resize the controls by changing their Location and Size properties in the Properties window. Invoking this command again unlocks the controls.

Tools

The Tools menu contains miscellaneous tools that do not fit particularly well in the other menus. It also contains a few duplicates of commands in other menus and commands that modify the IDE itself.

The following list describes the Tools menu's most useful commands. Note that some of these commands only appear when a particular type of editor is open.

  • Attach to Process — This command displays a dialog box to let you attach the debugger to a running process.

  • Connect to Database — This command displays the Connection Properties dialog box, where you can define a database connection. The connection is added to the Server Explorer window. You can later use the connection to define data adapters and other objects that use a database connection.

  • Connect to Server — This command displays a dialog box that lets you connect to a database server.

  • Code Snippets Manager — This command displays the Code Snippets Manager, which you can use to add and remove code snippets.

  • Choose Toolbox Items — This command displays a dialog box that lets you select the tools displayed in the Toolbox. For instance, some controls are not included in the Toolbox by default. You can use this command to add them if you will use them frequently.

  • Add-in Manager — This command displays the Add-in Manager, which lists the add-in projects registered on the computer. You can use the Add-in Manager to enable or disable these add-ins.

  • Macros — The Macros submenu contains commands that help you create, edit, and execute macros. See the section "Macros" later in this chapter for details.

  • Extension Manager — This command displays an Extension Manager dialog that lets you find Visual Studio extensions online and install them.

  • External Tools — This command displays a dialog box that lets you add and remove commands from the Tools menu. For example, you could add a command to launch WordPad, MS Paint, WinZip, and other handy utilities from the Tools menu.

  • Import/Export Settings — This command displays a dialog box that you can use to save, restore, or reset your Visual Studio IDE settings. Use this dialog box to configure your development environment for general development, project management, team test, Visual Basic, C#, C++, or Web development.

  • Customize — This command allows you to customize the Visual Studio IDE. See Chapter 3, "Customization," for details.

  • Options — This command allows you to specify options for the Visual Studio IDE. See the "Options" section later in this chapter for details.

Macros

The Macros submenu provides commands that help you create, edit, and execute macros that automate repetitive Visual Studio programming chores. If you must perform a series of actions many times, you can record a macro that performs them. Then you can call the macro repeatedly to perform the actions rather than executing them manually.

Some examples of macros that I've used in the past include code that:

  • Arranges controls in unusual ways, such as spacing picture boxes around the edge of a circle.

  • Generates a long series of statements that does the same thing to a bunch of text values (for example, makes Select Case statements for a series of text values).

  • Sets up a new dialog box by creating the OK and Cancel buttons, positioning them, setting their DialogResult properties, and setting the form's AcceptButton and CancelButton properties.

  • Building a name and address form with labels and text boxes that have appropriate Anchor properties.

Author John Mueller (www.mwt.net/~jmueller) uses similar macros to set up dialog boxes, create standard menus, and build standard event handlers. You have other ways to do these things, such as saving a pre-built dialog box for use as a template, or by using code snippets described later in this chapter, but macros are quick and easy.

After you have recorded a macro, you can edit the macro's code and make changes. For example, if you want to run the code a certain number of times, you can include it in a For loop. Often, a quick inspection of the code lets you figure out how to modify the macro to perform actions similar to (but not exactly the same as) the actions you originally recorded.

Most of the commands in the Macros submenu are self-explanatory. Use the Record TemporaryMacro command to record a macro for quick temporary use. When you select this command, a small window pops up that contains buttons you can click to suspend, finish, or cancel recording. Visual Studio saves the commands you execute in a macro named TemporaryMacro.

Select Run TemporaryMacro to run this macro. If you record a new TemporaryMacro, it overwrites the existing one without warning you. Select the Save TemporaryMacro command to rename the macro so you can record a new TemporaryMacro without destroying the previous one.

Select the Macro Explorer command to display the window shown in Figure 2-10. If you right-click a macro, the resulting pop-up menu lets you run, edit, rename, or delete the macro. Notice the Macro Explorer's predefined Samples section, which contains example macros that you can use or modify for your own use.

The Macro Explorer lets you edit, run, and delete macros.

Figure 2.10. The Macro Explorer lets you edit, run, and delete macros.

Sometimes when you perform a series of programming tasks many times, you have better ways to approach the problem than writing a macro. For example, you may be able to make your program repeat the steps inside a loop. Or you may be able to extract the common code into a subroutine and then call it repeatedly rather than repeating the code many times. In these cases, your application doesn't need to contain a long sequence of repetitive code that may be hard to debug and maintain.

Macros are generally most useful when you must write similar pieces of code that cannot be easily extracted into a routine and shared by different parts of the application. For example, suppose that you need to write event handlers for several dozen TextBox controls. You could record a macro while you write one of them. Then you could edit the macro to make it generate the others in a loop using different control names for each event handler. You could place the bulk of the event-handling code in a separate subroutine that each event handler would call. That would avoid the need for extensive duplicated code. (In fact, you could even use the AddHandler statement or a Handles clause to make all the controls use the same event handler.)

Macros are also useful for manipulating the IDE and performing IDE-related tasks. For example, you can write macros to show and hide your favorite toolbars, or to change whether the current file is opened read-only.

Options

The Tools menu's Options command displays the dialog box shown in Figure 2-11. This dialog box contains a huge number of pages of options that configure the Visual Studio IDE.

The Options dialog box lets you specify IDE options.

Figure 2.11. The Options dialog box lets you specify IDE options.

The following list describes the Options dialog box's most important categories:

  • Environment — Contains general IDE settings such as whether the IDE uses tabs or multiple windows to display documents, the number of items shown in the most recently used file lists, and how often the IDE saves AutoRecover information. The Fonts and Colors subsection lets you determine the colors used by the editors for different types of text. For example, comments are shown in green by default, but you can change this color.

  • Projects and Solutions — Contains the default settings for Option Explicit, Option Strict, and Option Compare.

  • Source Control — Contains entries that deal with the source code control system (for example, Visual SourceSafe). These systems provide file locking and differencing tools that let multiple developers work on the same project without interfering with each other.

  • Text Editor — Contains entries that specify the text editor's features. For example, you can use these pages to determine whether delimiters are highlighted, whether long lines are automatically wrapped, whether line numbers are displayed, and whether the editor provides smart indentation. The Basic

    The Options dialog box lets you specify IDE options.
  • Debugging — Contains debugging settings such as whether the debugger displays messages as modules are loaded and unloaded, whether it should make you confirm when deleting all breakpoints, and whether it should allow Edit-and-Continue.

  • Database Tools — Contains database parameters such as default lengths for fields of various types.

  • HTML Designer — Contains options for configuring HTML Designer. These options determine such settings as whether the designer starts in source or design view, and whether it displays Smart Tags for controls in design view.

  • Office Tools — Contains settings that specify how the keyboard should work when you use Excel or Word files within Visual Studio.

  • Test Tools — Contains settings that determine how testing tools behave.

  • Windows Forms Designer — Contains settings that control the Windows Forms Designer. For example, this section lets you determine whether the designer uses a snap-to grid or snap lines and how far apart grid points are.

Test

The Test menu contains commands that control the Visual Studio testing tools. These tools let you perform such actions as coverage testing (to see if every line of code is executed), regression testing (to see if changes to the code broke anything), and load testing (to see how the application performs with a lot of simulated users running at the same time).

The following list briefly describes the Test menu's commands:

  • New Test — Displays a dialog box that lets you create various kinds of tests for the application.

  • Load Metadata File — Lets you load a test metadata file. These XML files describe test lists, each of which can contain tests. This command lets you load test lists into different projects.

  • Create New Test List — Lets you make a new test list. Test lists let you group related tests so that you can execute them together. For example, you might have test lists for user interface testing, print tests, database tests, and so forth.

  • Run — Starts executing the currently active test project without the debugger.

  • Debug — Starts executing the currently active test project with the debugger.

  • Windows — Displays test-related windows including Test View, Test List Editor, Test Results, and Test Runs.

The Window menu contains commands that control Visual Studio's windows. Which commands are enabled depends on the type of window that has the focus. For example, if focus is on a code editor, the Split command is enabled and the Float, Dock, and Dock as Tabbed Document commands are disabled, but when the Solution Explorer window has the focus, the opposite is true.

The following list briefly describes the most useful of these commands:

  • Split — Splits a code window into two panes that can display different parts of the code at the same time. This command changes to Remove Split when you use it.

  • Float, Dock, Dock as Tabbed Document — Secondary windows such as the Toolbox, Solution Explorer, and Properties windows can be displayed as dockable, floating, or tabbed documents. A dockable window can be attached to the edges of the IDE or docked with other secondary windows. A floating window stays in its own independent window even if you drag it to a position where it would normally dock. A tabbed document window is displayed in the main editing area in the center of the IDE with the forms, classes, and other project files.

  • Auto Hide — Puts a secondary window in Auto Hide mode. The window disappears, and its title is displayed at the IDE's nearest edge. When you click the title or hover over it, the window reappears so that you can use it. If you click another window, this window hides itself again automatically.

  • Hide — Removes the window.

  • Auto Hide All — Makes all secondary windows enter Auto Hide mode.

  • New Horizontal Tab Group — Splits the main document window horizontally so that you can view two different documents at the same time.

  • New Vertical Tab Group — Splits the main document window vertically so that you can view two different documents at the same time.

  • Close All Documents — Closes all documents.

  • Reset Window Layout — Resets the window layout to a default configuration.

  • Form1.vb — The bottom part of the Window menu lists open documents such as form, code, and bitmap editors. The menu displays a checkmark next to the currently active document. You can select one of these entries to quickly view the corresponding document.

  • Windows — If you have too many open documents to display in the Window menu, select this command to see a list of the windows in a dialog. This dialog box lets you switch to another document, close one or more documents, or save documents. By pressing Ctrl+Click or Shift+Click you can select more than one document and quickly close them.

Help

The Help menu displays the usual assortment of help commands. You should be familiar with most of these from previous experience. The following list summarizes some of the more interesting non-standard commands:

  • Visual Studio Documentation — Opens Visual Studio documentation in a web browser.

  • MSDN Forums — Opens an MSDN community forums web page where you can post and search for answers to questions.

  • Report a Bug — Opens the Microsoft Developer Division Feedback Center where you can report bugs, make suggestions, and look for hot fixes for known problems.

  • Samples — Opens a Microsoft web page containing links to Visual Studio documentation and samples.

  • Customer Feedback Options — Displays a dialog that lets you indicate whether you want to participate in Microsoft's anonymous Customer Experience Improvement Program. If you join, Microsoft collects anonymous information about your system configuration and how you use its software.

  • Check for Updates — Check online for Visual Studio updates.

  • Technical Support — Opens a help page describing various support options. The page includes phone numbers and links to more information.

TOOLBARS

The Visual Studio toolbars are easy to rearrange. Simply grab the four gray dots on a toolbar's left or upper edge and drag the toolbar to its new position. If you drag a toolbar to one of the IDE's edges, it will dock there either horizontally (on the IDE's top or bottom edge) or vertically (on the IDE's left or right edge). If you drop a toolbar away from the IDE's edges, it becomes a floating window not docked to the IDE.

You can use the IDE's menu commands to determine which toolbars are visible, to determine what they contain, and to make custom toolbars of your own. See Chapter 3, "Customization," for more details.

Many menu commands are also available in standard toolbars. For example, the Debug toolbar contains many of the same commands that are in the Debug menu. If you use a set of menu commands frequently, you may want to display the corresponding toolbar to make using the commands easier. Alternatively, you can make your own custom toolbar and fill it with your favorite commands.

SECONDARY WINDOWS

You can rearrange secondary windows such as the Toolbox and Solution Explorer almost as easily as you can rearrange toolbars. Click and drag the window's title bar to move it. As the window moves, the IDE displays little blue icons to help you dock the window, as shown in Figure 2-12. This figure probably looks somewhat confusing, but it's fairly easy to use.

Use the IDE's docking icons to help you dock windows.

Figure 2.12. Use the IDE's docking icons to help you dock windows.

When you drag the window over another window, the IDE displays docking icons for the other window. In Figure 2-12, these are the five center most icons. The four icons on the sides dock the window to the corresponding edge of the other window.

The center icon places the dropped window in a tab within the other window.

When you drag the mouse over one of the docking icons, the IDE displays a pale blue rectangle to give you an idea of where the window will land if you drop it. In Figure 2-12, the mouse is over the main document window's right docking icon, so the blue rectangle shows the dropped window taking up the right half of the main document window.

If you drop a window somewhere other than on a docking icon, the window becomes free-floating.

When you drop a window on the main document area, it becomes a tabbed document within that area, and you cannot later pull it out. To free the window, select it and use the Window menu's Dock or Float command.

Sometimes the IDE is so cluttered with windows that it's hard to figure out exactly where the window will be dropped. It's usually fairly easy to just move the mouse around a bit and watch the pale blue rectangle to see what's happening.

The windows in the Microsoft Document Explorer used by the MSDN Library and other external help files provide the same arranging and docking tools for managing its subwindows such as Index, Contents, Help Favorites, Index Results, and Search Results.

This section describes some of the general features of the IDE's secondary windows. The following sections describe two of the most important of those secondary windows: the Toolbox and the Properties window.

Toolbox

The Toolbox window displays tools that you can use with the currently active document. The tools are available when you are editing a Windows Form, WPF Form, UserControl, web page, or other item that can contain objects such as controls and components.

The tools are grouped into sections called tabs, although they don't look much like the tabs on most documents. The Toolbox in Figure 2-13 displays tools for the Windows Forms Designer. The All Windows Forms section is showing its tools as icons whereas the Data section is listing its tools by name. Other tabs are hidden. In this figure, the Toolbox was enlarged greatly to show most of its contents. Most developers keep this window much smaller and docked to the left edge of the IDE.

You can customize the Toolbox by right-clicking a tab and selecting one of the commands in the context menu. The following list briefly describes the most useful of these commands:

The Toolbox window can display tools by name or icon.

Figure 2.13. The Toolbox window can display tools by name or icon.

  • List View — Toggles the current tab to display tools either as a list of names (as in the Data section in Figure 2-13) or a series of icons (as in the All Windows Forms section in Figure 2-13).

  • Show All — Shows or hides less commonly used tool tabs such as XML Schema, Dialog Editor, DataSet, Login, WPF Interoperability, Windows Workflow, Device Controls, and many others.

  • Choose Items — Displays the dialog box shown in Figure 2-14. Use the .NET Framework Components tab to select .NET tools, and use the COM Components tab to select COM tools. Click the Browse button to locate tools that are not in either list.

  • Sort Items Alphabetically — Sorts the items within a Toolbox tab alphabetically.

Use the Choose Toolbox Items dialog box to select the tools in the Toolbox.

Figure 2.14. Use the Choose Toolbox Items dialog box to select the tools in the Toolbox.

  • Reset Toolbox — Restores the Toolbox to a default configuration. This removes any items you may have added by using the Choose Items command.

  • Add Tab — Creates a new tab where you can place your favorite tools. You can drag tools from one tab to another. Hold down the Ctrl key while dragging to add a copy of the tool to the new tab without removing it from the old tab.

  • Delete Tab — Deletes a tab.

  • Rename Tab — Lets you rename a tab.

  • Move Up, Move Down — Moves the clicked tab up or down in the Toolbox. You can also click and drag the tabs to new positions.

If you right-click a tool in the Toolbox, the context menu *contains most of these commands plus Cut, Copy, Paste, Delete, and Rename Item.

Properties Window

When you are designing a form, the Properties window allows you to view and modify the properties of the form and of the controls that it contains. Figure 2-15 shows the Properties window displaying properties for a Button control named btnCalculate. You can see in the figure that the control's Text property is "Calculate" so that's what the button displays to the user.

Figure 2-15 shows some important features of the Properties window that deserve special mention. At the top of the window is a drop-down list that holds the names of all of the controls on the form. To select a control, you can either click it on the Windows Forms Designer or select it from this list.

The Properties window lets you view and modify control properties.

Figure 2.15. The Properties window lets you view and modify control properties.

The buttons in the row below the dropdown determine what items are displayed in the window and how they are arranged. If you click the leftmost button, the window lists properties grouped by category. For example, the Appearance category contains properties that affect the control's appearance such as BackColor, Font, and Image. If you click the second icon that holds the letters A and Z, the window lists the control's properties alphabetically.

Note

Arranging properties alphabetically makes finding properties easier for many developers.

The third icon makes the window display the control's properties and the fourth icon (which displays a lightning bolt) makes the window display the control's events instead. (Yes, it's a little odd that the Properties window displays either properties or events, but there is no Events window.)

For more information on using the Properties window to edit properties and create event handlers in the Windows Forms Designer, see Chapter 4, "Windows Forms Designer."

SUMMARY

The Visual Studio integrated development environment provides a huge number of tools for manipulating projects. Menus and toolbars contain hundreds if not thousands of commands for creating, loading, saving, and editing different kinds of projects and files.

This chapter describes the most useful and important commands available in the IDE's menus and toolbars. The kinds of menus, toolbars, and commands that are available depend on the type of window that currently has focus, in addition to the project's current state. For example, the Format menu contains commands that arrange controls on a form so it is only available when you are using a Windows Forms Designer.

Chapter 3, "Customization," explains in greater detail how you can rearrange Visual Studio's toolbars and menus to meet your needs. It explains how you can make your own toolbars and menus and fill them with the commands that you find most useful during your day-to-day development.

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

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