// Please use the following namespace
// using System.Windows.Forms;
// using GrapeCity.Win.Editors;
public void WireActionExecutingEvent()
{
// Creates an instace of the GcTextBox control.
GcTextBox gcTextBox1 = new GcTextBox();
// Creates an instace of the GcShortcut component.
GcShortcut gcShortcut1 = new GcShortcut();
// Sets the Alt + C to execute the clear behavior.
gcShortcut1.SetShortcuts(gcTextBox1, new ShortcutCollection(new Keys[] { Keys.Alt | Keys.C }, new object[] { gcTextBox1 }, new string[] { "ShortcutClear" }));
gcShortcut1.ActionExecuting += new EventHandler<ActionExecutingEventArgs>(OnShortcutActionExecuting);
}
private void OnShortcutActionExecuting(object sender, ActionExecutingEventArgs e)
{
if (e.Target is GcTextBox && (e.Target as GcTextBox).DroppedDown && e.ShortcutKey == (Keys.Alt | Keys.C) && e.ActionName == "ShortcutClear")
{
// When the drop down window opened, executes the clear action.
e.CanExecute = true;
}
}
' Please use the following namespace
' Imports System.Windows.Forms;
' Imports GrapeCity.Win.Editors;
Public Sub WireActionExecutingEvent()
' Creates an instace of the GcTextBox control.
Dim gcTextBox1 As New GcTextBox()
' Creates an instace of the GcShortcut component.
Dim gcShortcut1 As New GcShortcut()
' Sets the Alt + C to execute the clear behavior.
gcShortcut1.SetShortcuts(gcTextBox1, New ShortcutCollection(New Keys() {Keys.Alt Or Keys.C}, New Object() {gcTextBox1}, New String() {"ShortcutClear"}))
AddHandler gcShortcut1.ActionExecuting, AddressOf OnShortcutActionExecuting
End Sub
Private Sub OnShortcutActionExecuting(ByVal sender As Object, ByVal e As ActionExecutingEventArgs)
If TypeOf e.Target Is GcTextBox AndAlso TryCast(e.Target, GcTextBox).DroppedDown AndAlso e.ShortcutKey = (Keys.Alt Or Keys.C) AndAlso e.ActionName = "ShortcutClear" Then
' When the drop down window opened, executes the clear action.
e.CanExecute = True
End If
End Sub