Condividi tramite


FileCodeModel2.Remove(Object) Method

Definition

Removes the specified code element from the source file.

public:
 void Remove(System::Object ^ Element);
public:
 void Remove(Platform::Object ^ Element);
void Remove(winrt::Windows::Foundation::IInspectable const & Element);
[System.Runtime.InteropServices.DispId(16)]
public void Remove (object Element);
[<System.Runtime.InteropServices.DispId(16)>]
abstract member Remove : obj -> unit
Public Sub Remove (Element As Object)

Parameters

Element
Object

Required. A CodeElement object or the name of a code element to remove from the source code.

Implements

Attributes

Examples

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  

Remarks

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.

Applies to