This class provides some useful methods for the handling of CAB commands.


The static AddInvoker method adds new user interface items as invoker for the specified command.

Example: Add two user interface items to the same command:

presenter.WorkItem.Commands[CommandNames.Open].AddInvoker(openToolStripMenuItem, "Click");
presenter.WorkItem.Commands[CommandNames.Open].AddInvoker(openToolStripButton, "Click");

The same as the previous code example but with the help of CommandHelper:

CommandHelper.AddInvoker(presenter.WorkItem, CommandNames.Open, openToolStripMenuItem, openToolStripButton);

Note: The difference of the two approaches is that the CommandHelper also initialize the user interface items with the command status.


This static method simplifies the changing of a command status. Especially if the command status should be dependent on a boolean value. In the following code example the command status depends on the boolean field "enabled":

if (enabled) presenter.WorkItem.Commands[CommandNames.ShowDevice].Status = CommandStatus.Enabled;
else presenter.WorkItem.Commands[CommandNames.ShowDevice].Status = CommandStatus.Disabled;

The next code example shows the same by using the CommandHelper:

CommandHelper.SetStatus(presenter.WorkItem, CommandNames.ShowDevice, enabled);

Last edited Oct 3, 2007 at 2:22 PM by jbe2277, version 1


No comments yet.