FileCodeModel::Remove Method (Object^)
Visual Studio 2015
Removes the specified code element from the source file.
Assembly: EnvDTE (in EnvDTE.dll)
Parameters
- Element
-
Type:
System::Object^
Required. A CodeElement object or the name of a code element to remove from the source code.
Element can be either a CodeElement object in the collection, or the name of a unique element in the collection.
Individual elements do not have a Remove method because they can exist in multiple collections. To remove a specific element, you must call the Remove method of its container object.
Sub RemoveExample(ByVal dte As DTE2) ' Before running this example, open a code document from a project ' and place the insertion point inside a function. Try ' Retrieve the CodeFunction at the insertion point. Dim sel As TextSelection = _ CType(dte.ActiveDocument.Selection, TextSelection) Dim fun As CodeFunction = _ CType(sel.ActivePoint.CodeElement( _ vsCMElement.vsCMElementFunction), CodeFunction) If MsgBox("Remove " & fun.Name & "?", MsgBoxStyle.YesNo) = _ MsgBoxResult.Yes Then ' Remove the function. fun.ProjectItem.FileCodeModel.Remove(fun) End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Show: