Export (0) Print
Expand All
Cut
Run
Expand Minimize

AddNewItem Method

Visual Studio .NET 2003

Adds a new item to the current project.

[Visual Basic .NET]
Public Function AddNewItem( _
   Optional ByVal Item As String, _
   Optional ByVal Name As String = "" _
) As ProjectItem
[Visual Basic 6]
Function AddNewItem( _
   Optional ByVal Item As String, _
   Optional ByVal Name As String = "" _
) As ProjectItem
[C++]
HRESULT __stdcall AddNewItem(
   BSTR Item,
   BSTR Name,
   /* [out, retval] */ ProjectItem** retVal
);
[C#]
public ProjectItem AddNewItem(
   string Item,
   string Name
);
[JScript .NET]
public function AddNewItem(
   Item : String,
   Name : String
) : ProjectItem

Parameters

Item
Optional. The virtual path based on the tree nodes in the New File dialog box. Item comes from the left pane and Name from the right pane. For example, to add a new HTML file to a Visual Basic .NET project, you would use "General\HTML Page".
Name
Optional. The display name to use for the item when it is added to a project.

Return Value

Returns a ProjectItem object.

Remarks

AddNewItem models the New File dialog box. The contents of this dialog box vary depending on the type of project. To add items to a project using this method, look at the items available for the project in the New File dialog box.

Example

Sub AddNewItemExample()
   Dim ItemOp As ItemOperations
   ItemOp = DTE.ItemOperations
   ItemOp.AddNewItem("General\Text File", "A new text file")
End Sub

See Also

Applies To: ItemOperations Object

Show:
© 2014 Microsoft