Command on ToolStripTextBox

Topics: CAB & Smart Client Software Factory
Feb 1, 2007 at 7:45 AM
Hi,

I want to extend a toolbar with a ToolStripTextBox, wire it with a command and execute that command only if the ENTER-key is pressed. The command handler (defined with the CommanHandlerAttribute) should not get only the EventArgs.Empty object as event argument, but a custom event argument object.

Is that possible with CAB?

Regards
ibisxin
Feb 5, 2007 at 1:21 PM
Given your requirement for EventArgs, you may have to use an Event instead of a Command.
Feb 5, 2007 at 1:43 PM
Thanks Ragoczy,

I found another solution - but I had to change a CAB class a little bit: I created my own CommandAdapter for the ToolStripTextBox by extending Microsoft.Practices.CompositeUI.Commands.EventCommandAdapter<TInvoker> and overriding the ExcecuteCommand. To do that it was necessary to set the ExecuteCommand in the EventCommandAdapter<..> class to virtual.

public class ToolStripTextBoxEventCommandAdapter : EventCommandAdapter<ToolStripTextBox>
{
   ...
 
   public override event EventHandler ExecuteCommand;
 
   public new void InvokerEventHandler(object sender, EventArgs e)
   {
      KeyPressEventArgs keyPressArgs = e as KeyPressEventArgs;
      ...
 
      ExcecuteCommand(this, new MyEventArgs(..));
   }
}

Regards
ibisxin