Search
Schedule.ExecuteCommand Method
See Also
 






Executes the specified command on this schedule.

Namespace: MindFusion.Scheduling
Assembly: MindFusion.Scheduling

 Syntax

C#  Copy Code

public void ExecuteCommand (
    Command command
)

Visual Basic  Copy Code

Public Sub ExecuteCommand( _
    command As Command _
)

 Parameters

command

The Command to execute.

 Remarks

If undo/redo is enabled, the command is saved in the undo history or added to the active composite command.

AddItemCommand and RemoveItemCommand objects are created automatically by the control when adding or removing items, both programmatically or interactively. Calling this method explicitly could be necessary in order to save item's state for later undo using a ChangeItemCommand, or to run a custom operation represented by a class derived from Command.

 Example

The following example shows the pattern that should be used to save the state of an item for later undo.

C#  Copy Code

Item item = calendar.ItemSelection.Items[0];
if (item != null)
{
    ChangeItemCommand change = new ChangeItemCommand(calendar.Schedule, item);
    item.HeaderText = "new header";
    item.StartTime = DateTime.Now;
    item.EndTime = DateTime.Now.AddHours(2);
    calendar.Schedule.ExecuteCommand(change);
}

Visual Basic  Copy Code

Dim item = calendar.ItemSelection.Items(0)
If (item IsNot Nothing) Then

    Dim change As New ChangeItemCommand(calendar.Schedule, item)
    item.HeaderText = "new header"
    item.StartTime = DateTime.Now
    item.EndTime = DateTime.Now.AddHours(2)
    calendar.Schedule.ExecuteCommand(change)

End If

 See Also