Select the Multiple Startup Projects option (see Figure 2-27), and set the appropriate action for each project (None, Start, or Start Without Debugging).
Figure 2-27
Then when you press F5, the projects configured to start launch at the same time.
Properties
The Properties window shows the list of properties associated with the various items in your projects (Windows Forms, controls, projects, solutions, etc).
Figure 2-28 shows the Properties window displaying the list of properties of a Windows Form (Form1, in this example). By default, the properties are displayed in Categorized view, but you can change it to Alphabetical view, which lists all the properties in alphabetical order.
Figure 2-28
All default property values are displayed in normal font, while nondefault values are displayed in bold. This feature is very useful for debugging because it enables you to quickly trace the property values that you have changed.
Besides displaying properties of items, the Properties window also displays events. When the Properties window is displaying an item (such as a Windows Form or a control) that supports events, you can click the Events icon (see left side of Figure 2-29) to view the list of events supported by that item. To create an event handler stub for an event, simply double-click the event name and Visual Studio 2008 automatically creates an event handler for you (see right side of Figure 2-29).
Figure 2-29
Error List
The Error List window (see Figure 2-30) is used to display:
□ Errors, warnings, and messages produced as you edit and compile code.
□ Syntax errors noted by IntelliSense.
Figure 2-30
To display the Error List window, select View→Error List.
You can double-click on an error message to open the source file and locate the position of the error. Once the error is located, press F1 for help.
Output Window
The Output window (View→Output) displays status messages for your application when you are debugging in Visual Studio 2008. The Output window is useful for displaying debugging messages in your application. For example, you can use the Console.WriteLine()
statement to display a message to the Output window:
Console.WriteLine(DateTime.Now.ToString());
Figure 2-31 shows the message displayed in the Output window.
Figure 2-31
Designer Window
The Designer window enables you to visually design the UI of your application. Depending on the type of projects you are creating, the Designer displays a different design surface where you can drag and drop controls onto it. Figure 2-32 shows the Designer for creating different types of projects — Windows Forms (left), Windows Mobile (right), and Web (bottom left).
Figure 2-32
To switch to the code-behind of the application, you can either double-click on the surface of the designer, or right-click the item in Solution Explorer and select View Code. For example, if you are developing a Windows Forms application, you can right-click on a form, say Form1.cs
, in Solution Explorer and select View Code. The code-behind for Form1
then displays (see Figure 2-33).
Figure 2-33
Code View
Code view is where you write the code for your application. You can switch between design view and code view by clicking on the relevant tabs (see Figure 2-34).
Figure 2-34
In Visual Studio, you can right-click on the tabs (see Figure 2-35) to arrange the code view either horizontally or vertically, to maximize the use of your monitor(s).
Figure 2-35
Figure 2-36 shows the code view and design view displaying horizontally.
Figure 2-36
Figure 2-37 shows the code view and design view displaying vertically.
Figure 2-37
Having multiple views at the same time is useful if you have a big monitor (or multiple monitors).
Within the code view of Visual Studio 2008 is the Code and Text Editor, which provides several rich features that make editing your code easy and efficient, including:
□ Code Snippets
□ IntelliSense statement completion
□ IntelliSense support for object properties, methods and events
□ Refactoring support
The Code Snippet feature in Visual Studio 2008 enables you to insert commonly used code blocks into your project, thereby improving the efficiency of your development process. To insert a code snippet, right-click on the location where you want to insert the code snippet in the Code Editor, and select Insert Snippet (see Figure 2-38).
Figure 2-38
Select the snippet category by clicking on the category name (see the top of Figure 2-39) and then selecting the code snippet you want to insert (see bottom of Figure 2-39).
Figure 2-39
For example, suppose that you select the try
code snippet. The following block of code will be inserted automatically:
private void Form1_Load(object sender, EventArgs e) {
try {
} catch (Exception) {
throw;
}
}
You can also use the Surround With code snippets feature. Suppose that you have the following statements:
private void Form1_Load(object sender, EventArgs e) {
int num1 = 5;
int num2 = 0;
int result = num1 / num2;
}
The third statement is dangerous because it could result in a division-by-zero runtime error, so it would be good to wrap the code in a try-сatch
block. To do so, you can highlight the block of code you want to put within a try-сatch
block and right-click it. Select Surround With (see Figure 2-40), and then select the try code snippet.
Читать дальше