Create Your Own Project Item Templates in VS 2005
Use the Project Item Template
To use the template, add the .vstemplate file and the code file to a zip file. (Windows XP supports zip files, or you can use WinZip). Place the zipped file in \My Documents\Visual Studio\ItemTemplates\Visual Basic. Restart Visual Studio 2005 and you will see a section in the Add New Item dialog under My Templates name Typed Collection (see Figure 1). Select this item to add a typed collection to any project.
Figure 1: The Typed Collection Project Item Template in Visual Studio 2005
A good technique is to build your template code and test it first. Once you remove any syntax errors or bugs, replace the literal values with template tokens and complete the process of moving the template files to the My Documents folder.
After you have created the template, use it to add an item to a test project.
Create Templates to Jumpstart Development
To create a project item template, create the stubbed source file and an XML file with a .vstemplate extension. The XML file describes your template to the IDE. Place all of the code files and the .vstemplate file in a zipped file and move it to the \My Documents\Visual Studio\ItemTemplates\Visual Basic\ folder, and it is ready to use.
Creating templates can help jumpstart application development and make it much easier to use even the most advanced features of Visual Studio and Visual Basic. In 2005, this process is even easier.
About the Author
Paul Kimmel is the VB Today columnist for www.codeguru.com and has written several books on object-oriented programming and .NET. Check out his book Visual Basic .NET Power Coding from Addison-Wesley and his upcoming book UML DeMystified from McGraw-Hill/Osborne (Spring 2005). Paul is also the founder and chief architect for Software Conceptions, Inc, founded 1990. He is available to help design and build software worldwide. You may contact him for consulting opportunities or technology questions at email@example.com.
If you are interested in joining, sponsoring a meeting, or posting a job, check out www.glugnet.org, the Web page of the Greater Lansing area Users Group for .NET.
Copyright © 2005 by Paul T. Kimmel. All Rights Reserved.
Page 2 of 2