FileCodeModel2.Remove(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从源文件删除指定的代码元素。
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 其容器对象的方法。