Recipe 3.4. Creating Other Item Types


Problem

Are there any other types of files or items I can add to a Visual Basic project?

Solution

The Add New Item dialog, accessed through the Project Add New Item menu command, includes a large selection of template choices. Select the one that meets your needs. Some templates use a different default file extension than the standard .vb extension.

Discussion

Here are the Visual Basicspecific template choices installed by default with Visual Studio 2005 Professional Edition:


Windows Form

Adds a blank Windows form, derived from System.Windows.Forms.Form.


Dialog

Adds a new Windows "dialog-style" form to your project, derived from System.Windows.Forms.Form. The form includes basic OK and Cancel buttons and is con-figured for typical dialog presentation.


Explorer Form

Adds a new Windows form to your project that has the basic look and functionality of the Windows File Explorer (explorer.exe). The main area of the form combines TReeView and ListView controls that provide an interface to the file system.


MDI Parent Form

If you are designing a Multi Document Interface (MDI) application, this form represents the parent that will include the various child "document" forms.


About Box

Adds a new "About" form to your project. This is a standard Windows form, pre-designed to look like a typical About form. It automatically fills in application-specific details such as the version number. You must add the code elsewhere in your project to display this form.


Login Form

Adds a new "Login" form to your project. This form includes the "look and feel" of a login form only; you must supply authentication code on your own.


Splash Screen

Adds a new "Splash Screen" form to your project. This form appears as your application performs basic initialization during startup.


Class

Adds a new class file to your project, containing an empty class definition named according to the filename you provide.


Module

Adds a new module file to your project, containing an empty module definition named according to the filename you provide.


Interface

Adds a new interface file to your project, containing an empty interface definition named according to the filename you provide. By custom, interface names always begin with a capital letter "I."


Component Class

Adds a new "component" to your project, derived from System.ComponentModel.Component. The .NET component model provides basic interaction services for classes defined as components. All Windows Forms controls are components.


COM Class

Adds a new class file to your project that exposes COM interface features. This is done via the ComClassAttribute attribute. All exposed interfaces have to be marshaled across the managed .NET boundary, although .NET performs most of the difficult work for you.


Data Set

Adds a new data set to your project with an .xsd file extension. These data sets provide a visual design experience to underlying data stores, such as databases. You can include queried data from several data sources.


SQL Database

Adds a new SQL Server database file with an .mdf file extension. This file is managed by SQL Server, and you must have that product installed to use this item type.


Report

Visual Studio includes its own banded report writer that you can use to create data reports. This item adds a new report with an .rdlc file extension. The report designer interacts with data sources defined in your application.


Crystal Report

Crystal Reports is a third-party banded reporting tool included with Visual Studio. This item adds a new Crystal Report to your application with an " .rpt" file extension. Enhanced versions of the Crystal Reports product are available from its vendor, Business Objects. (Crystal Reports has passed through several owner-ship changes since its initial version. Business Objects is the owner as of this writing.)


User Control

Adds a new user control file to your application, derived from System.Windows.Forms.UserControl. User controls contain full user interaction functionality, similar to the controls already included in the Visual Studio Toolbox. You can build your control from other controls in the Toolbox or from scratch by managing all input and display needs.


Inherited Form

Adds a new form based on another form already found in your project. When selected, Visual Studio displays the Inheritance Picker dialog with a list of all forms in your project. Visual Studio must be able to create an instance of each potential form. Therefore, you must have built your project at least once, including the form to be inherited. Also, the Inheritance Picker will exclude any form marked as MustInherit. You can manually create inherited forms using the Inherits keyword.


Inherited User Control

Adds a new user control based on another user control already found in your project. When selected, Visual Studio displays the Inheritance Picker dialog with a list of all user controls in your project. Visual Studio must be able to create an instance of each potential user control. Therefore, you must have built your project at least once, including the user control to be inherited. Also, the Inheritance Picker will exclude any user control marked as MustInherit. You can manually create inherited controls using the Inherits keyword.


Custom Control

Creates a new user control but with more emphasis on controls that will contain no existing subordinate controls. You will manage the full display of the control yourself.


Web Custom Control

Creates a new web control for use in ASP.NET applications that's similar to the controls supplied with the Web Forms package. You are responsible for all HTML rendering code.


Resources File

Adds a new resource file to your project, with an .resx file extension. New Windows Forms projects already include a project-focused resource file.


Settings File

Adds a " .settings" file to your application that stores application-or user-specific settings. Windows Forms applications already include both kinds of settings support.


Code File

Adds a blank code file to your project. The file will be completely empty, waiting for you to add a class, module, structure, or other content.


Class Diagram

Adds a new class diagram file with a .cd file extension. Class diagrams let you define classes, structures, interfaces, and other basic types using a visual designer interface. Visual Studio manages the other files in your application as you make changes to the class diagram.


XML File

Adds a new XML (Extensible Markup Language) file with an .xml file extension. Visual Studio includes basic IntelliSense support for editing XML files.


XML Schema

Adds a new XSD (XML Schema Definition) file with an .xsd file extension. XSD files can be used to validate XML data.


XSLT File

Adds a new XSLT (Extensible Stylesheet Language Transformation) file with an .xslt file extension. XSLT files are used to transform XML data into another format (either XML or any other format).


Text File

Adds a blank text file to your project with a .txt file extension. You can add any text to this file that you wish.


HTML Page

Adds a new HTML file with an .htm file extension. Visual Studio includes extended support for editing web pages.


Bitmap File

Adds a new bitmap file with a .bmp file extension that you can edit directly in Visual Studio.


Cursor File

Adds a new icon file with a .cur file extension that you can edit directly in Visual Studio.


Icon File

Adds a new icon file with an .ico file extension that you can edit directly in Visual Studio.


Application Configuration File

Adds a new .config settings file to your application. This file is often used to con-figure an application from .NET's point of view. To store application-and user-specific usage settings, consider a settings file instead.


Transactional Component

Adds a new transactional component that manages the lifetime of some data, resource, or activity. These components inherit from the System.EnterpriseServices.ServicedComponent class and exist mainly to interact within COM+ environments.


Installer Class

Adds an installer class you can use to create custom installation scenarios for .NET applications. For typical .NET applications, you should consider creating a standard deployment project instead.


Windows Service

Adds a class that supports the creation of a Windows Service. Services have no direct user interface, so you should not add this template to a Windows Forms application.

If you use one of the other Visual Studio editions, such as the Express Edition, the list of available templates may differ. If you have installed third-party products that enhance Visual Studio, you may see additional templates related to those products.

The My Templates section of the Add New Item dialog includes custom file templates that you have added yourself, primarily through the Export Template Wizard available through the File Export Template menu command.

See Also

This recipe does not discuss the types of items you can add to an ASP.NET web project. See the recipes in Chapter 17 for additional information on creating web projects.




Visual Basic 2005 Cookbook(c) Solutions for VB 2005 Programmers
Visual Basic 2005 Cookbook: Solutions for VB 2005 Programmers (Cookbooks (OReilly))
ISBN: 0596101775
EAN: 2147483647
Year: 2006
Pages: 400

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net