First, the basic concept of the code template so-called "code template" is a source of code that has been part of the code. When adding a new Class file or FORM file to Project, VS.NET IDE will copy these template files as a new file. The file name of the new file is the file name entered in the Add New Item dialog. VS.NET IDE can automatically change Class Name in the template file to a new class name.
Using the code template, you can improve the work efficiency of some typical coding work, such as: (1) Automatically add an annotation block for recording the author, create a date, maintenance history, etc. (2) Automatically add the imports statement.
Second, the simplest code template to join the code that you want to include a declarative copyright in each class file, you can follow the steps: (1) Browse to the following path with the Windows Explorer: C: / Program Files / Microsoft Visual Studio .NET 2003 / VB7 / VBWIZARDS / CLASS / TEMPLATES / 1033 (2) Find the class.vb file, open with Notepad, the content should be: public class [! Output safe_item_name] End Class
(3) Modify its contents:
'' Copyright (c) 2004 grapecity inc. All rights [! Output safe_item_name] End Class
(4) Save and shut down (5) Start VS.NET, create a new Windows Application Project (6) Add a new class file class1.vb. This new Class already contains a copyright statement comment code.
Third, the method above the more complex code template will result in any new Class File from any project. If more flexibility is desired, allow developers to be selected, create custom code templates, which appears in the Add New Item dialog as a new category. Specific steps are as follows:
Repost from http://support.microsoft.com/?kbid=870715
This Step-by-Step Article Describes How To create a Custom Code Template In A Microsoft Visual C # .NET Windows Application Project and The Add It To The Visual Studio .NET IDE.
To create a Custom Code Template In A Microsoft Visual C # .NET Windows Application Project and The Add It To The Visual Studio .NET IDE, FOLLOW THESE Steps.
Change the localprojectItems.vsdir file
Right-Click My Computer, And The Click Explore. Locate The LocalProjectItems Folder.
In Microsoft Visual Studio .NET 2003, the folder is located in the following path: C: / Program Files / Microsoft Visual Studio .NET 2003 / VC # / CSharpProjectItems / LocalProjectItemsIn Microsoft Visual Studio .NET, the folder is located in the following path :: C: / Program Files / Microsoft Visual Studio .NET / VC # / CSHARPPROJECTITEMS / LOCALPROJECTITEMS
Note C represents the hard disk drive where you installed Visual Studio .NET. Create a new MyCustomTemplates folder in the LocalProjectItems folder. Copy the LocalProjectItems.vsdir file to the MyCustomTemplates folder.
In Microsoft Visual Studio .NET 2003, the LocalProjectItems.vsdir file is located in the following path: C: / Program Files / Microsoft Visual Studio .NET 2003 / VC # / CSharpProjectItems / LocalProjectItems
In Microsoft Visual Studio .NET, The LocalProjectItems.vsdir File Is Located in The Following Path: C: C: / Program Files / Microsoft Visual Studio .NET / VC # / CSHARPPROJECTITEMS / LOCALPROJECTITEMS
5.?in the mycustomtemplates folder, Open the localprojectItem.vsdir file by using notepad, and then replace the existing text with the following text:
. ../..MYCUSTOMTEMPLATESWINFORMWIZ.VSZ| (FAE04EC1-301F-11D3-BF4B-00C04F79EFBC }|) 2 7 3} | | | # # | | | | | | | | | | | | | | | | | |
6.?save the file, and then quit notepad.
Back to the top
Create a Custom Windows Form Wizard
1.? Open the csharpprojectItems folder.
In Visual Studio .NET 2003, The Folder Is Located in The Following Path: C: C: / Program Files / Microsoft Visual Studio .NET 2003 / VC # / CSHARPPROJECTITEMS
In Visual Studio .NET, The Folder Is Located in The Following Path: C: / Program Files / Microsoft Visual Studio .NET / VC # / CSHARPPROJECTITEMS
2.?Copy the CSharpAddWinFormWiz.vsz file to the CSharpProjectItems folder, and then rename the file to MyCustomTemplatesWinFormWiz.vsz 3.?Open the MyCustomTemplatesWinFormWiz.vsz file by using Notepad, and then change the wizard name parameter value to the following:. Param = "Wizard_name = mycustomtemplateswinformWiz"
4.?save the file, and then quit notepad.
Create a Custom Windows Form Template
1.? Open the vc # wizards folder.
In Visual Studio .NET 2003, The Folder Is Located in The Following Path: C: C: C: C: C: / Program Files / Microsoft Visual Studio .NET 2003 / VC # / VC # Wizards
In Visual Studio .NET, The Folder Is Located in The Following Path: C: / Program Files / Microsoft Visual Studio .NET / VC # / VC # Wizards
2.?Copy the CSharpAddWinFormWiz folder to the VC # Wizards folder, and then change the name of the the CSharpAddWinFormWiz folder to MyCustomTemplatesWinFormWiz. 3.?Double-click the MyCustomTemplatesWinFormWiz folder, open the Templates folder, and then double-click the 1033 folder 4.?dd The next, qit. 6.?save the file, and then quit notepad.cs file. 6.?save the file, and then quit notepad.cs The Template in Visual Studio .NET
1.?tart Visual Studio .Net. 2.?on The File Menu, Point To New, And The Click Project. 3.?under Project Types, Click Visual C # Projects. 4.?Under Templates, Click WindowsApplication. 5.? Click OK By default, the Form1 form appears 6.?On the Project menu, click Add New Item The Add New Item -... Your Windows Application dialog box appears.Note Your Windows Application is a placeholder for the name of the Windows application that you created. 7.?Under Categories, expand Local Project Items, click MyCustomTemplates, and then click Open. By default, the Form2.cs file is created. 8.?Right-click the Form2 form, and then click View Code. 9.?The code that you see is the code that you added in step 5 of the "Create a custom Windows form template" section.REFERENCESFor more information, visit the following Microsoft Web site: http://msdn.microsoft.com/ Library / default.asp? url = / library / en-us / vsent7 / html / vxorienterpriseTemplates.asp
?