Partager via


WorkflowDesignerLoader.RemoveActivityFromDesigner(Activity) Méthode

Définition

Supprime une activité de l'hôte de concepteur une fois celle-ci ajoutée à la collection d'activités parentes.

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)

Paramètres

activity
Activity

Activité à supprimer du concepteur.

Exemples

L'exemple suivant montre comment supprimer une activité du WorkflowDesignerLoader. Avant d’être supprimée du WorkflowDesignerLoader, la dernière activité enfant du workflow est supprimée de la collection Activities du workflow.

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

S’applique à