FileCodeModel2.Remove(Object) Метод

Определение

Удаляет указанный элемент кода из исходного файла.

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)

Параметры

Element
Object

Обязательный. Удаляемый из исходного кода объект CodeElement или имя элемента кода.

Реализации

Атрибуты

Примеры

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  

Комментарии

Element может быть либо CodeElement объектом в коллекции, либо именем уникального элемента в коллекции.

Отдельные элементы не имеют метода, Remove так как они могут существовать в нескольких коллекциях. Чтобы удалить конкретный элемент, необходимо вызвать Remove метод его объекта-контейнера.

Применяется к