Executing a Command from Listbox

Topics: CAB & Smart Client Software Factory
May 7, 2007 at 5:37 PM
Hi,
at first, sorry for this long posting.
I have the following class:
public class ExList : Peter.Infrastructure.Interface.Commands.ICommand
{
string text;
Command cmd;
public ExList(string text,Command command)
{
this.text = text;
this.cmd = command;
}
public override string ToString()
{
return this.text;
}
#region ICommand Member
public void Execute()
{
// ???????????????
}

#endregion
}
to add Items to a Listbox. This ListBox is used as a Smartpart in OutlookbarWorkSpace.

So something like this:
ExList ex = this.listBox1.SelectedItem as ExList;
if (ex != null)
{
ex.Execute();
}
else
{
MessageBox.Show("no command");
}

a) did i have to register each of this commands??
b) I'm looking for a way to Execute the Command set by the Constructor.

or did anybody have a better idea???
Thanks in advance
Peter