Share via


FileCodeModel2.Remove メソッド

指定したコード要素をソース ファイルから削除します。

名前空間:  EnvDTE80
アセンブリ:  EnvDTE80 (EnvDTE80.dll 内)

構文

'宣言
Sub Remove ( _
    Element As Object _
)
void Remove(
    Object Element
)
void Remove(
    Object^ Element
)
abstract Remove : 
        Element:Object -> unit
function Remove(
    Element : Object
)

パラメーター

  • Element
    型 : Object

    必須。 ソース コードから削除する CodeElement オブジェクトまたはコード要素の名前です。

解説

Element には、コレクション内の CodeElement オブジェクトを指定することも、コレクション内の一意の要素の名前を指定することもできます。

それぞれの要素には、Remove メソッドはありません。これは、要素が複数のコレクションに存在する可能性があるためです。 特定の要素を削除するには、その要素のコンテナー オブジェクトの Remove メソッドを呼び出す必要があります。

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

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

FileCodeModel2 インターフェイス

EnvDTE80 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する