2.3. The Integrated Development Environment (IDE)The VS2005 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. But more important than the physical layout of the IDE is the productivity boost it provides to you, the developer. You can visually drag controls from the toolbox onto a design window or a code window. In code editing windows , Intellisense automatically pops up a list of all the available members for any given situation. Syntax errors are highighted in code windows, signalling a problem even before you try to compile the project. The list goes on: a little time invested getting familiar with the IDE will reap tremendous payback. 2.3.1. LayoutVS2005 consists of a single parent window, which contains multiple windows. All the menus, toolbars, design and editing windows, and miscellaneous other windows are associated with the single parent window. A typical layout of the IDE is shown in Figure 2-7. Basically, it consists of a menu and toolbar arrangement across the top and a work surface below, flanked by other toolbars and windows. Figure 2-7. Typical IDE layoutWhen working on content files, such as page, user control, or master page files, which all have visual content, you have your choice of two different views, selectable by tabs at the bottom of the screen. Design view shows the content in a WYSIWYG mode. Source view shows the source code for the content, that is, the server control declarations, any HTML and static content, and any script blocks on the page.
VS2005 has a title bar across the top with menus below. Under the menus are toolbars with buttons that duplicate many of the common menu commands. Nearly everything that can be done through menus can also be done with context-sensitive pop-up menus, as described in the discussion that follows . You can easily customize the menu and toolbars 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. You move the toolbars by grabbing them with the mouse and dragging them where you want. Figure 2-7 shows a Source view of a web form, with the Source window occupying the work surface in the center of the screen. When you click the Design button at the bottom of the window, the work surface will display a visual representation of the page. In either Design or Source view, you can drag and drop controls, components , or data sources from the Toolbox or Server Explorer onto the page. In Design view, this puts an accurate visual representation on the page. In Source view, it puts the control or component declaration in the source code. You can work in either mode, switching to whatever is most convenient at the moment, editing in either mode and seeing those results in either mode.
Along the right side of the screen are two windows, both of which will be covered in more detail later in this chapter. The upper window is the Solution Explorer. Below that is the Properties window. Many other similar windows are available to you as will be described. Right-clicking on the title bar of a dockable window pops up a menu with five mutually exclusive check items:
In the upper-right corner of the window are two buttons: a pushpin and an X. The pushpin toggles the AutoHide property of the window. The X is the standard close window button. The work surface uses a tabbed metaphor, meaning the tabs along the top edge of that window indicate there are other windows below it. You can change to a Multiple Document Interface (MDI) style, if you prefer, in Tools Options Environment General. You will find navigational aids along the bottom of the work surface. Depending on the context, there may be one or more buttons. When you're looking at a web page, for example, as shown in Figures 2-7 and 2-8, two buttons labeled Design and Source allow switching between the design view and underlying source code. Buttons represent the HTML hierarchy of the page, seen as <body> and <div> buttons in Figure 2-8. The cursor in the code window or the focus in Design view dictates which objects will be represented as buttons: one button for the current level and one more for each parent level. Clicking on any of the buttons highlights that level of code in the code window. When you switch from a design window to a code window, the menu items, toolbars, and toolbox change in a context-sensitive manner. Figure 2-8. Design view window in IDEThe code window has context-sensitive drop-down lists at the top of the screen for navigating around the application. In the HTML editor, the left drop-down lists Client Objects & Events and Client Script, and the right drop-down lists event handlers. In the C# code editor, the left drop-down contains a list of all the classes in the code, and the right drop-down has a list of all the objects in the current class. The left margin of a code window shows a yellow bar next to lines that have been changed and a green bar next to lines that have been saved. This color coding is per session; it resets when the project is first loaded. 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. 2.3.2. Building and RunningYou can run your application at any time by selecting either Start or Start Without Debugging from the Debug menu, or you can accomplish the same results by pressing F5 or Ctrl-F5, respectively. In addition, you can start the program by clicking the Start icon ( ) on the Standard toolbar . The program can be built (i.e., .exe and .dll files generated) by selecting a command under the Build menu . You have the option of building the entire solution or only the currently selected project. For a full discussion of application deployment, please see Chapter 19. 2.3.3. Menus and ToolbarsThe menus provide access to many of the commands and capabilities of VS2005. The more commonly used menu commands are duplicated with toolbar buttons for ease of use. The menus and toolbars are context-sensitive (i.e., the available selection is dependent 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 will be the following:
If the current window is a design window, the Data, Format, and Layout menu commands will also become available, for example. Many of the menu items have keyboard shortcuts , listed adjacent to the menu item itself. Look over the list of shortcut keys in Appendix A; many of them will become indispensible to your daily development effort. The following sections describe some of the menu items and their submenus, focusing on those aspects that are interesting and different from common Windows commands. 2.3.4. File MenuThe File menu provides access to a number of file-related, project-related, and solution- related commands. Many of these commands are context sensitive. Below are descriptions of those commands that are not self-explanatory.
2.3.4.1. NewAs in most Windows applications, the New menu item creates new items that you can work on in the application. In VS2005, the New menu item has four submenu items, to handle the different possibilities:
Figure 2-9. Add New Item dialog boxThe New command has an equivalent button in the Standard toolbar , which exposes the New Project and New Web Site commands. 2.3.4.2. OpenThe Open menu item is used to open preexisting items. It has four submenu items:
2.3.4.3. AddThe Add menu item gives you options for adding a new or existing project or a new or existing web site to a pre-existing solution. 2.3.4.4. 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, which allows you to set the encoding option and line ending character(s) for the file. 2.3.4.5. Source ControlThe Source Control submenu item allows you to interact with your source control program if it is installed, such as Visual Source Safe. 2.3.5. Edit MenuThe Edit menu contains the text editing and searching commands that one would expect but also includes commands useful in editing code. The most useful are discussed in this section. 2.3.5.1. Cycle Clipboard Ring (Ctrl-Shift-V)The Clipboard Ring is like copy and paste on steroids. You can copy a number of different selections to the Windows clipboard, using the Edit Cut (Ctrl X) or Edit Copy (Ctrl-C) commands. Then, you can use Ctrl-Shift-V to cycle through all the selections, allowing you to paste the correct one when it comes around. This submenu item is context-sensitive and is visible only when editing a code window. 2.3.5.2. Finding and replacingVS2005 offers a number of useful options for finding and replacing text, both in the current file and in a range of files. Quick Find (Ctrl-F) / Quick Replace (Ctrl-H) . These slightly jazzed names are for slightly jazzed versions of the typical Find and Replace. Both commands call essentially the same dialog boxes, switchable by a tab at the top of the dialog box, as shown in Figures 2-10 and 2-11. Figure 2-10. Find and Replace dialog box: Quick Find tabThe search string defaults to the text currently selected in the code window or, if nothing is selected, to the text immediately after the current cursor location. The Look in drop-down offers the choice of the Current Document, All Open Documents, the Current Project, and the current method. Figure 2-11. Find and Replace dialog box: Quick Replace tabYou can expand or collapse the search options by clicking on the plus/minus button next to Find Options. By default, Search hidden text is checked, which allows the search to include code sections currently collapsed in the code window. The Use checkbox allows the use of regular expressions (see the sidebar) or wildcards. If the Use checkbox is checked, the Expression Builder button to the right of the Find what textbox will become enabled, providing a handy way to insert valid regular expression or wildcard characters . Once a search string has been entered in the Find what textbox, the Find Next button becomes enabled. In Quick Find mode is a Bookmark All button, which finds all occurrences of the search string and places a bookmark (described in the Bookmarks section later in this chapter) next to the code. In Quick Replace mode, there is also a Replace with text box, and buttons for replacing either a single or all occurrences of the search string. Find in Files (Ctrl-Shift-F) . Find in Files is a powerful search utility that finds text strings anywhere in a directory or in subdirectories ( subfolders ). It presents the dialog box shown in Figure 2-12. Checkboxes present several self-explanatory options, including the ability to search using wildcards or regular expressions. Replace in Files (Ctrl-Shift-H) . Replace in Files is identical to the Find in Files command, described in the previous section, except that it allows you to replace the target text string with a replacement text string. If you click on the Replace in Files tab at the top of the Find and Replace dialog box shown in Figure 2-12, you will get the Replace in Files dialog box shown in Figure 2-13. Figure 2-12. Find and Replace dialog box: Find in Files tab
This command is useful for renaming forms, classes, namespaces, projects and so on. Renaming objects is a common requirement because you don't want to be saddled with the default names assigned by VS2005. Renaming should not be difficult, but it can be. Object names are spread throughout a project, often hidden in obscure locations such as solution files, and throughout source code files. Though all of these files are text files and can be searched and edited, it can be a tedious and error-prone task. The Replace in Files command makes it simple, thorough, and reasonably safe. Of course, you can always undo a Find and Replace operation if you make a mistake. Find Symbol (Alt-F12) . Clicking on this command will bring up the Find Symbol dialog box shown in Figure 2-14. This allows you to search for symbols (such as namespaces, classes, and interfaces) and their members (such as properties, methods , events, and variables ). It also allows you to search in external components for which the source code is unavailable. Figure 2-13. Find and Replace dialog box: Replace in Files tabFigure 2-14. Find and Replace dialog box: Find Symbol tabThe 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. 2.3.5.3. Go To...This command 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 is visible only when editing a text window. 2.3.5.4. Insert File As Text...This command 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 is visible only when editing a text window. A standard file browsing dialog box is presented for searching for the file to be inserted. The default file extension will correspond to the project language, but you can search for any file with any extension. 2.3.5.5. AdvancedThe context-sensitive Advanced command is visible only when editing a code window. It has many submenu items. These include commands for the following:
2.3.5.6. Incremental search (Ctrl-I)Incremental search allows you to 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 command on the Advanced submenu 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 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 earlier). 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 2-2 apply to incremental searching. Table 2-2. Incremental searching
2.3.5.7. BookmarksBookmarks are useful for marking spots in your code and easily navigating to them later. Several context-sensitive commands are on the Bookmarks submenu (listed in Table 2-3, along with their shortcut key combinations). Unless you add the item to the task list, bookmarks are lost when you close the file though they are saved when you close the solution (as long the file was still open). Table 2-3. Bookmark commands
This menu item only appears when a code window is the current window. 2.3.5.8. OutliningVS2005 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 ( ). Clicking on the plus sign expands the region. You can nest the outlined regions , so one section can contain one or more other collapsed sections. Several commands facilitate outlining shown in Table 2-4. Table 2-4. Outlining commands
You can set the default behavior for outlining with the Tools Options menu item. Go to Text Editor and then the specific language for which you want to set the options. The outlining options can be set for VS2005 under Basic VB Specific and for C# under C# Advanced. 2.3.5.9. IntelliSenseMicrosoft Intellisense technology makes the lives of programmers much easier. It has real-time, context-sensitive help available, which appears under your cursor. Code completion automatically completes words for you, reducing your typing. Drop-down-lists provide all methods and properties possible in the current context, available at a keystroke or mouse click. Unlike previous versions of Visual Studio, Intellisense works in all code windows, including the C# code-behind files, but also within server-side (script) and client-side (HTML) code in content files, i.e., in .aspx and .ascx files. The default Intellisense features can be configured by going to Tools Options and then the language-specific pages under Text Editor. Most of the 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 2-5. Table 2-5. Intellisense commands
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. There are icons for methods, fields, properties, events, etc. 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.
Table 2-6 lists all the different icons used in the member lists and other windows throughout the IDE. The accessibility icons are listed in Table 2-7. Table 2-6. Object icons
Table 2-7. Object accessibility icons
Two of the subcommands under the Intellisense menu item, Insert Snippet... and Surround With..., tap into a great feature to reduce typing and minimize errors: code snippets . A code snippet is a chunk of code that replaces an alias. For example, the alias switch would be replaced with the following: switch ( switch_on ) { default: } After the replacement, the switch expression switch_on is highlighted in yellow and the cursor is in place, ready to type in your own expression. In fact, all the editable fields will be highlighted, and you can use the Tab key to navigate through them or Shift-Tab to go backward. Any changes made to the editable field are immediately propagated to all the instances of that field in the code snippet. Press Enter or Esc to end the field editing and return to normal editing. To do a straight alias replacement, select Insert Snippet from the menu or, more easily, press Ctrl-K, Ctrl-X. Alternatively, type an alias in the code window and an Intellisense menu will pop up with a list of aliases , with the current one highlighted. Press the Tab key to insert that code snippet. Alternatively, a code snippet can surround highlighted lines of code, say with a for construct. To surround lines of code with a code snippet construct, highlight the code and then select Surround With from the menu or press Ctrl-K, Ctrl-S. 2.3.6. View MenuThe View menu provides access to the myriad windows available in the VS2005 IDE. You will probably keep many of these windows open all the time; others you will use rarely, if at all. When the application is running, a number of other windows, primarily used for debugging, become visible or available. You can access these windows via the Debug Windows menu item, not from the View menu item. VS2005 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, not per-project or per-solution. This section discusses those areas that may not be self-explanatory. 2.3.6.1. Solution Explorer (Ctrl-Alt-L)You use the Solution Explorer to manage projects and solutions. Solution Explorer presents the solution and projects and all the files, folders, and items contained within them in a hierarchical, visual manner. The Solution Explorer is typically visible in a window along the upper right side of the VS2005 screen though the Solution Explorer window can be closed or undocked and moved to other locations, like all the windows accessible from the View menu. A typical Solution Explorer is shown in Figure 2-15. Figure 2-15. Solution ExplorerYou will find several menu buttons along the top of the Solution Explorer window. These buttons are context-sensitive, meaning they may or may not appear, depending on the currently selected item in the Solution Explorer. Table 2-8 details the purpose of each button. Table 2-8. Solution Explorer buttons
You can display miscellaneous files in the Solution Explorer: Go to Tools Options..., then go to Environment Documents. Check the checkbox labeled Show Miscellaneous files in Solution Explorer. Most of the functionality of the Solution Explorer is redundant with the VS2005 menu items, though performing a given chore in Solution Explorer rather than in the menus is often easier and more intuitive. Right-clicking on any item in the Solution Explorer will pop up a context-sensitive menu. Three different pop-up menus from Solution Explorer are shown in Figure 2-16. From left to right, they are for a solution, a web page, and a source code file. Figure 2-16. Solution Explorer context-sensitive menus for solutions, web pages, and source filesSome of the context-sensitive menus are not redundant with any of the menu commands:
2.3.6.2. 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, Figure 2-17. Add Reference dialog boxopen data connections, access and edit database information, access message queues and performance counters, and more. A typical Server Explorer is shown in Figure 2-18. It is a hierarchical view of the available servers. In this figure, two servers available are: sony290 (on which resides the Northwind database) and virt-sony290 (which is the local machine). The figure shows a drill-down into a data connection, showing the tables in the Northwind database. These tables, and all other objects in this tree view, are directly accessible and editable from the window. Figure 2-18. Server Explorer2.3.6.3. Properties Windows (F4)The Properties window displays all the properties for the currently selected item. Some of the properties (such as Font) may have subproperties , indicated by a plus sign next to their entries in the window. The property values on the right side of the window are editable. One thing that can be confusing is that certain items have more than one set of properties. For example, a Form content file can show two different sets of properties, depending on if you select the source file in the Solution Explorer or the form, as shown in the Design view. A typical Properties window while in Design view is shown in Figure 2-19. Figure 2-19. Properties windowThe name and type of the current object is displayed in the field at the top of the window. In Figure 2-19, it is an object named btnPage2 of type Button, contained in the System.Web.UI.WebControls namespace. Most properties can be edited either in the Properties window or declaratively (that is, manually) in the Source view . The Font property has subproperties that may be set directly in the Properties window by clicking on the plus sign to expand its subproperties and then editing the subproperties in place. The Properties window has several buttons below the name and type of the object. The first two buttons on the left toggle the list by category or alphabetically . The next two buttons from the left (visible only in Design view) toggle between displaying properties for the selected item and displaying events for the selected item. The rightmost button displays property pages for the object if there are any.
The box below the list of properties displays a brief description of the selected property. 2.3.6.4. Visible Borders (Ctrl-Q)This menu item is only available in Design view and toggles the display of borders around controls on the page or user control. 2.3.6.5. Details (Ctrl- Shift-Q)This menu item is only available in Design view and toggles the display of items such as HTML breaks, spans and divs. 2.3.6.6. Non Visual Controls (Ctrl- Shift-N)This menu item is only available in Design view and toggles the display of non visual controls, such as data source controls (described in Chapter 9) and Web Parts controls (described in Chapter 13). 2.3.6.7. Object Browser (Ctrl-Alt-J)The Object Browser is a tool for examining objects (such as namespaces, classes, and interfaces) and their members (such as methods, properties, variables, and events). A typical Object Browser window is shown in Figure 2-20. 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 Tables 2-6 and 2-7. Right-clicking on an object or a member brings up a context-sensitive pop-up menu with various menu options. 2.3.6.8. Document Outline (Ctrl- Alt-T)The Document Outline menu item is available in either Design or Source view when a page or user control is visible on the work surface. Figure 2-20. Object BrowserThe Document Outline displays the hierarchical structure of a web page or user control, including directives, script blocks, HTML elements, and server controls, as shown in Figure 2-21. Clicking on any item in the Document Outline will immediately select that item on the work surface but not vice versa. 2.3.6.9. Error List (Ctrl-W, Ctrl-E)Available in all editor views, the Error List window displays errors, warnings, and messages generated as you edit and compile your project. Syntax errors flagged by Intellisense are displayed here, as well as deployment errors. Double-clicking on an error in this list will open the offending file and move the cursor to the error location. 2.3.6.10. Task List (Ctrl-W, Ctrl-T)In large applications, keeping a to-do list can help. VS2005 provides this functionality with the Task List window. You can provide shortcuts to comments in the Task List along with token strings, such as TODO, HACK, or UNDONE. Also, the compiler populates the Task List with any compile errors. Clicking on a line in the Task List will take you to the relevant line of code in the code editor. Figure 2-21. Document Outline2.3.6.11. Toolbox (Ctrl-Alt-X)Displays the toolbox if it is not currently displayed. If it is currently displayed, nothing happens, and it does not toggle the display. To undisplay the toolbox, click on the X in the toolbox title bar. 2.3.6.12. Command window (Ctrl-Alt-A)The Command window is used to enter commands directly, 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 using Tools Customize.) For a complete discussion of command window usage, consult the SDK documentation. 2.3.6.13. Other windowsSeveral other windows have been relegated to a submenu called Other Windows:
2.3.7. Refactor MenuRefactoring, to quote the Microsoft MSDN Library for VS2005, "is the process of improving your code after it has been written, by changing the internal structure of the code without changing the external behavior of the code." What this means in English is that after you write your code, you may make code changes to enhance readability and maintainability. VS2005 makes this easy.
The Refactor menu item is available when you're looking at a code window for a web page, user control, or language source code file. It is also available from context menus when you right-click on an identifier in a Class View, Object Browser, or Solution Explorer window. The refactoring menu items will modify your code, for example, extracting common code to a method and then calling that method in the place from which it was extracted. Refactoring can also be used to rename methods, and all references to the renamed method will automatically be updated as well across all files in the project and across all projects of the same language. Before any changes are committed, an optional Preview Changes dialog box will appear, giving you the opportunity to accept or cancel the changes. A project that is unable to build successfully can still be refactored, though ambiguous references might not update properly. The following functions are available under the Refactor menu item:
2.3.8. Website MenuThis menu item mostly provides redundancy with, and works in conjunction with, the Solution Explorer. It allows you to add new or existing items, references, or web references, all affecting the current selection in the Solution Explorer. These menu items have been described previously in this chapter. In addition, it provides other menu items, some of which are redundant with the Solution Explorer, some of which are not. 2.3.8.1. Start OptionsOpens the Property Pages dialog box with the Start Options for the current web site shown in Figure 2-23. This allows you to specify settings such as the start page or URL, the server to use, and the debugger to use. This menu item is unavailable on the Solution Explorer. 2.3.8.2. Copy Web SiteThis menu item, which is also available as an icon at the top of the Solution Explorer, allows you to easily copy all or part of a web site to a new web site. If the new web site does not exist, it will create it. It brings up the window shown in Figure 2-24. To copy a web site, click on the Connections drop down at the top of the window. Then navigate to the target location. If the target location does not exist, you will be prompted to create it. Highlight the files and folders on the left you wish to copy and then click the rightward- facing arrow in the middle to copy those selected items. A number of other self-explanatory controls exist, such as buttons for refreshing the list, deleting items, synchronizing the directories, and viewing the log. Figure 2-23. Start OptionsFigure 2-24. Copy Web siteThis process does not create an IIS virtual directory for the new web site, so if you are using virtual directories (necessary for deployment, for example), you will have to make the virtual directory manually. To do so, right-click on My Computer or go to Control Panel Administrative Tools Computer Management and drill down through Services and Applications Internet Information Services Web Sites to Default Web Site. Then right-click and select New Virtual Directory and follow the wizard. 2.3.8.3. ASP.NET ConfigurationThis menu item is also available as an icon at the top of the Solution Explorer. It brings up the ASP.NET Web Site Administration Tool, which will be covered in detail in Chapter 18. 2.3.9. Project MenuThe Project menu provides functionality related to project management. It is only visible when the solution is selected in the Solution Explorer. All of the functionality exposed by the Project menu is available in the Solution Explorer by right-clicking on the solution. Accomplishing your goals in Solution Explorer is often easier and more intuitive, but the menus lend themselves to keyboard use. Each of the commands under this menu pertain to the object currently highlighted in the Solution Explorer. 2.3.9.1. Add New Item... (Ctrl-Shift-A)This command brings up the Add New Solution dialog box, which lets you add new items based on templates, such as a text file, style sheet, class file, etc. This command is not for adding a new project to the solution; that is done with the File New New Project command. 2.3.9.2. Add Existing Item... (Shift-Alt-A)This command brings up the Add Existing Item - Solution Items dialog box, which allows you to browse your filesystem for existing items to add to the solution. 2.3.9.3. Add New Solution FolderSolution folders are used to organize solution items within a solution. This command lets you add a folder to the solution. These solution folders are virtual, meaning no corresponding physical folder is on your filesystem. Instead, the solution folders are remembered within the solution file ( .sln ). Any solution items added to the solution folder are physically stored in the project file along with the .sln file and other solution items. 2.3.9.4. Set StartUp Projects...Visual Studio must know which project, or projects, in a solution will be the startup project(s). This command brings up the Solution Properties Pages dialog box, with the Startup Project page displayed. You can either select the current project as the startup project, any specified project from the solution, or multiple projects. By default, the first project created in a solution becomes the startup project. If multiple projects are selected, the startup page for each project will execute sequentially, so multiple browser windows will be opened. 2.3.9.5. Project Dependencies... / Project Build Order...These commands, visible only when a solution contains multiple projects, present the Project Dependiencies dialog box that allows you to control the dependencies and build order of the projects in a solution. You can also access this dialog from the Solution Explorer by right-clicking a solution. The dialog box has two tabs, one for Dependencies and one for Build Order. For each project in a solution, the Project Dependencies tab allows you to specify which projects it depends upon. The dependent projects will be built first. The Project Build Order tab presents a list of all the projects in the order in which they will be built. You can't change the Build Order from this tab. It is inferred from the dependencies. 2.3.10. Build MenuThe 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 19. 2.3.11. Debug MenuThe 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 will be covered along with the topic of debugging in Chapter 7. 2.3.12. Data MenuThis context-sensitive menu is visible only when in design mode. It is not available when editing code pages. The commands under it are available when appropriate data controls are on the form. Data controls and data binding will be covered in Chapters 9 and 10. 2.3.13. Format MenuThe Format menu is visible only in design mode, and the commands under it are context-sensitive to the control(s) currently selected. This menu offers the ability to control the size and layout of controls, though many of the menu options are grayed out for certain web form controls. You can:
To operate on more than one control, select the controls in one of several ways:
When you operate on more than one control, the last control selected 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 control selected. Likewise, if aligning a group of controls, they will all align with the last control selected. As controls are selected, they will display eight resizing handles. These resizing handles will be black for all the selected controls except the baseline, or last control, which will have white handles. With that in mind, all of the commands under the Format menu are fairly self- explanatory. 2.3.14. Tools MenuThe Tools menu presents commands accessing a wide range of functionality, ranging from connecting to databases to accessing external tools to setting IDE options. Some of the more useful commands are described in the following sections. 2.3.14.1. Connect to Device...Brings up a dialog box that allows you to connect to either a physical mobile device or an emulator. 2.3.14.2. Connect to Database...The Connect to Database command default 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 Change... button allows you to connect to any number of other databases, including any for which there are Oracle or ODBC providers. 2.3.14.3. Code Snippets Manager (Ctrl-K, Ctrl-B)This command brings up the Code Snippets Manager dialog box, which allows you to maintain the code snippets , described above in the Intellisense section. This dialog box allows you to add or remove code snippets for any of the supported languages. You can import code snippets and search online for code snippets. 2.3.14.4. Choose Toolbox Items...This command brings up the Choose Toolbox dialog box shown in Figure 2-25. 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 (which include registered COM components and .NET components in specific directoriesyou can browse for .NET components if they are not listed) are listed in one or the other. In either case, check or uncheck the box in front of the component to include or not include the desired component. Figure 2-25. Choose Toolbox Items dialog box
You can sort the components listed in the dialog box by clicking on the column head that you wish to sort by. 2.3.14.5. MacrosMacros are a wonderful feature that allow you to automate tasks in the IDE. Macros can either be coded by hand using VS2005 or recorded as you perform the desired task. If you allow the IDE to record the macro for you, 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 Microsoft Excel.
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. You can save the macro with the Macros Save TemporaryMacro command, which will automatically bring up the Macro Explorer, described next. You manage macros with the Macro Explorer window, accessed via a submenu of the Macros command or by pressing Alt-F8, shown in Figure 2-26 after recording a temporary macro. Figure 2-26. Macro ExplorerRight-clicking on a macro in the Macro Explorer pops up a menu with four items:
All the 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 a folder called VSMacros80 in the current projects 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 will allow you to 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. So, for example, the macro called TemporaryMacro shown in Figure 2-26 is the TemporaryMacro subroutine contained in the module named RecordingModule , which is part of the MyMacros project. 2.3.14.6. External Tools...Depending on the options selected at the time VS2005 was installed on your machine, you may have one or more external tools available on the Tools menu. These might include tools such as Create GUID or Dotfuscator Community Edition. (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 you select it, 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, and several checkboxes for different behaviors. 2.3.14.7. Import and Export Settings...This command brings up the Import and Export Settings dialog box, which is a wizard for importing and exporting IDE environment settings. With this wizard, you can transfer your carefully wrought IDE settings from one machine to the next. 2.3.14.8. Customize...The Customize... command allows you to customize many aspects of the IDE user interface. (The Options... command, described in the following section, allows you to set other program options.) It brings up the Customize dialog box, which has two different tabs plus one additional button, allowing customization in three different areas.
2.3.14.9. Options...The Options... command brings up the Options dialog box. This dialog box allows setting a wide range of options, ranging from the number of items to display in lists of recently used items to HTML 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 of the 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. 2.3.15. Window MenuThe Window menu is a standard Windows application Window command. It displays a list of all the currently open windows, allowing you to bring any window to the foreground by clicking on it. All the file windows currently displayed in the IDE have tabs along the top edge of the work surface, below the toolbars (unless you have selected MDI mode in Tools Options Environment General), and windows can be selected by clicking on a tab. This is a context-sensitive menu. The menu items available for different circumstances are listed in Table 2-9. Table 2-9. Window menu item commands
2.3.16. Help MenuThe Help menu provides access to a number of submenus. Those that are not self- explanatory are described here. 2.3.16.1. Dynamic Help (Ctrl-Alt-F4)If you are developing on a machine with enough horsepower, Dynamic Help is a wonderful thing. Otherwise, it is quite a performance hog. (You can disable it by unchecking all the checkboxes under Tools Options Environment Dynamic Help) Alternatively, closing the window is sufficient to prevent the performance hit, and that way it is available when you need it. That said, using Dynamic Help is 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, the context-sensitive hyperlinks will appear in the Dynamic Help window. Click on any of these links to bring up the relevant help topic in a separate window. 2.3.16.2. 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 using the different search types using the same phrase.
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. 2.3.16.3. Index Results... (Shift-Alt-F2)When you're searching for Help topics by Index, many topics are often for a given index entry. In these cases, the multiple topics are listed in an Index Results window. This window will display automatically if this is the case. This command allows you to view the Index Results window if it has been closed. 2.3.16.4. Check for UpdatesThis command will check for service releases for your currently installed version of VS2005. In order for this command to work, your machine must be connected to the Internet. If there is an update available, you will be prompted to close the IDE before the service release is installed. |