Imports::Remove Method (Object^)

 

Removes an imports statement from the Imports collection. The imports statement to be removed may be indexed by either the string specifying the import or by a one-based index.

Namespace:   VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)

void Remove(
	Object^ index
)

Parameters

index
Type: System::Object^

Required. Either a one-based index into the collection, or the imports statement string to remove.

An error is generated if the imports statement does not exist in the collection. If you use a string index, the string must be an exact match for the imports statement. For example, an index of "SomeNamespace" will not remove the imports statement "SomeNamespace.*".

' Macro Editor
Imports VSLangProj
Public Sub RemoveImport()
   ' Project must be a Visual Basic project.
   Try
      Dim vsproject As VSProject = _
         CType(DTE.Solution.Projects.Item(1).Object, VSProject)
      vsproject.Imports.Remove("SomeAlias = SomeNamespace.*")
      vsproject.Imports.Remove(1)
   Catch e As System.Exception
      MsgBox(e.Message)
   End Try
End Sub
Return to top
Show: