共用方式為


WorkflowDesignerLoader.RemoveActivityFromDesigner(Activity) 方法

定義

將活動加入至父活動集合後,再將活動從設計工具主應用程式中移除。

public:
 void RemoveActivityFromDesigner(System::Workflow::ComponentModel::Activity ^ activity);
public void RemoveActivityFromDesigner (System.Workflow.ComponentModel.Activity activity);
member this.RemoveActivityFromDesigner : System.Workflow.ComponentModel.Activity -> unit
Public Sub RemoveActivityFromDesigner (activity As Activity)

參數

activity
Activity

要從設計工具中移除的活動。

範例

下列範例顯示如何從 WorkflowDesignerLoader 移除活動。 在移除工作流程中 WorkflowDesignerLoader 的最後一個子活動之前,會先從工作流程的 Activities 集合中移除該活動。

public void RemoveLastChildActivity()
{
    IDesignerHost designerHost = (IDesignerHost)GetService(typeof(IDesignerHost));
    CompositeActivity rootActivity = designerHost.RootComponent as CompositeActivity;

    if (rootActivity.Activities.Count > 0)
    {
        Activity activityToRemove = rootActivity.Activities[rootActivity.Activities.Count - 1];
        rootActivity.Activities.Remove(activityToRemove);
        this.RemoveActivityFromDesigner(activityToRemove);
    }
}
Public Sub RemoveLastChildActivity()
    Dim designerHost As IDesignerHost = CType(GetService(GetType(IDesignerHost)), IDesignerHost)
    Dim rootActivity As CompositeActivity = CType(designerHost.RootComponent, CompositeActivity)

    If rootActivity.Activities.Count > 0 Then
        Dim activityToRemove As Activity = rootActivity.Activities(rootActivity.Activities.Count - 1)
        rootActivity.Activities.Remove(activityToRemove)
        Me.RemoveActivityFromDesigner(activityToRemove)
    End If
End Sub

適用於