Using Views


Visual Basic .NET Unleashed
By Paul Kimmel
Table of Contents
Chapter 1.  Using the Unified Visual Studio IDE

Using Views

Several views are available in Visual Studio to help you manage what is going on in the development process. Some of these views will be familiar to Visual Basic 6 developers and others are unique to .NET.

Let's take a moment to go over some of the Visual Studio View menu items.

Solution Explorer

Visual Studio is an enterprise development tool. The Solution Explorer contains a solution-level view. When you are developing in Visual Basic .NET, a solution is similar to a .VBG, Visual Basic group .

A solution can contain one or more projects (see Figure 1.8). The Solution Explorer shows the solution at the top of the view and each project grouped within the solution. Each element in the solution view has a different context menu, accessed by selecting the element and right-clicking, with appropriate menu choices for that element. For example, when you create an add-in, the wizard will create a Visual Studio Deployment Project (.vdproj) as part of the solution. The Deployment Project will contain menu items for building, deploying, running Windows Installer to install and uninstall the AddIn, and options for managing related information such as the Registry settings.

Figure 1.8. A view of the Solution Explorer containing the HelloWorld.sln solution.


From Figure 1.8, we see the HelloWorld solution containing the HelloWorld project. The HelloWorld project is a console application containing References, AssemblyInfo.vb, and Module1.vb. Module1 contains the source code. The References section contains references to external components , projects, and COM objects.

Database, Visual Modeler, and Visual Analyzer projects are contained in solutions (.SLN files) and will therefore be managed in the Solution Explorer.

Class View

The Class view contains information similar to the Solution view except that the Class view organizes data from the object-oriented perspective of the data.

Using Figure 1.9 as a guide, you are looking at the Class view of the HelloWorld solution, the HelloWorld project, the Module, and the members of that module. The only member of module1 is Main, shown in the figure.

Figure 1.9. The Class view of HelloWorld.


The module is most closely related to a class that contains all Shared members. The Class view will be helpful because Visual Basic .NET allows you to define multiple modules and classes per file. When you are looking at the Class view in Figure 1.9, remember that the unit of encapsulation is no longer the file. The relationship in Visual Basic 6 was one module or one class per one .bas file or .cls file respectively. Both classes and modules are contained in .vb files, and the relationship is one file to many definitions.

For more information on object-oriented topics, like the class idiom, refer to Part II. Shared members are covered in Chapter 11, "Shared Members."

Server Explorer

The Server Explorer view allows you to manage several kinds of server applications that are accessible from your network.

Open the Server Explorer to browse or interact with database servers, Web Services, and Windows services. You can drag and drop elements from the Server Explorer to your applications, and Visual Studio .NET will add the related components to your application and complete the correct connectivity information.

Resource View

Manage .rc Windows resource files in your project from the Resource View window. Refer to the help section on Creating a New Resource Script file in the VS .NET help for more information on this subject.

Properties Window

Press F4 to open the Properties window. The Properties window is a context-based view of the design-time properties of components. The selected component is displayed in the drop-down list box and properties for the selected component are displayed and modifiable beneath the selected object.


The toolbox has a substantial number of components that you can drag and drop onto your applications. The kind of application you are working on will affect the tools shown in the box. If you are working on a Windows application, the toolbox will contain WinForm components. On the other hand, if you are working on a Web application, WebForm components will be available in the toolbox.

Read the chapters in Part II for more on programming with components, including programming with GDI+.

Pending Check-ins

Source Control is tightly integrated into Visual Studio. The Pending Check-ins view contains modified files in the current solution. Use Source Control at project inception to protect your intellectual property.

The Source Control view allows you to customize the default behavior of source control for Visual Studio.

Web Browser

The View menu contains a Web Browser startup menu for convenience. This is illustrative of the tightly integrated relationship between Visual Studio .NET and Internet development.

The Web Browser view of the General folder (under Tools, Options) contains such information as the Home Page and Search Page. By default the Home Page is vs:/default.htm and the Search Page is If you choose View, Web Browser, Show Browser, by default you get the Visual Studio Start Page, which is the vs://default.htm page.

When the browser is started from Visual Studio, it's displayed as an integrated browser.

Other Windows

Several miscellaneous views can help you resolve development issues and manage your projects in Visual Studio. These views are mentioned here briefly and will be mentioned in this book when they are beneficial to our discussion.

Task List

The Task List is context-based. Different views, like the code editor or compiler, place elements in the Task List. Use the Task List, as mentioned earlier, to help track and resolve outstanding issues.

Document Outline

The Document Outline feature is similar to the Class view feature. Class view provides you with a hierarchical view of elements in your Windows applications; the Document Outline provides you with a hierarchical view of elements in your HTML and WebForms. (Refer to Figure 1.10 for an example.)

Figure 1.10. Document Outline view displays a control and HTML tag-based view of your Web form.


Click an element in the Document Outline view and Visual Studio will navigate you to that element on your Web form.

Command or Immediate Window

The Immediate window performs double duty as the Immediate window, similar to its VB6 role and the Command window, which is a new role devised for VB .NET.

To open the Command window, select View, Other Windows, Command Window in Visual Studio. By default the window is opened in command mode. The command mode is used to issue commands directly to Visual Studio .NET.

To switch from command mode to immediate mode, type immed at the > prompt in the Command window. Immediate mode plays the same role as it did in VB6; the Immediate window is for debugging. Switch back to command mode by typing >cmd in the Command window while in Immediate mode. For a list of commands, refer to the Help Topic "Visual Studio Commands with Arguments."

An example of a Visual Studio command you can execute in the Command window is

 ? MyVar 

where MyVar is a variable defined in the current procedure. You can also issue more complex commands like


The previous command will display the QuickWatch dialog box with the variable MyVar and its value displayed.

Output Window

The Output window displays output from compilation as well as text written using the Debug object. For example, if you write System.Diagnostics.Debug.WriteLine("This is a test!"), the text "This is a test!" (without the quotes) will be written to the Output window.

Debug text is written to the Immediate window in VB6. In VB .NET, debug information is written to the Output window.

Macro Explorer

The Macro Explorer contains macros defined for use with Visual Studio .NET. The Macro Explorer allows you to manage macros.

When you create a macro, the Macro Designer runs, and you can modify and test the macro in the designer. You will be surprised at how much implementing macros in Visual Studio .NET is like writing Visual Basic code. Follow these steps to create a spoof macro named JelloMold.

  1. Choose View, Other Windows, Macro Explorer.

  2. Right-click MyMacros in the Macro Explorer and select New Module.

  3. Visual Studio will run the Macro Designer and create a new module. Add the following code to the module:

     Sub JelloMold() MsgBox("Jello Mold") End Sub 
  4. Close the Macro Designer, saving the macro.

  5. Back in Visual Studio, open the Command window.

  6. In the Command window, type


When you run the macro, you should get a simple dialog box with the text Jello Mold displayed. The way macros are stored and behave is consistent with the way Visual Basic namespaces, classes, modules, and methods behave.

This example was a trivial one, just to keep things moving. You will find macros and the Automation Extensibility Model useful over time for automating development tasks . We will look at some practical uses for macros in Chapter 4.

Object Browser

The Object Browser view is very similar to the VB6 Object Browser. The biggest difference is one of semantics. You have to keep in mind that you are looking at namespaces, and although namespaces are similar to reference libraries, the underlying technology is different.

Figure 1.11 contains a shot of the Object Browser focused on the TextBoxBase class, the superclass for TextBox. The Visual Studio .NET Object Browser is used in the same manner as the VB6 Object Browser; that is, to get a handle on the architecture, including an accessible view of the methods, properties, and events defined for a class.

Figure 1.11. The Object Browser showing the methods, properties, and events of the TextBoxBase class.



Visual BasicR. NET Unleashed
Visual BasicR. NET Unleashed
Year: 2001
Pages: 222 © 2008-2017.
If you may any questions please contact us: