为什么不使用KeyDown CTRL + KEY?

时间:2011-05-23 18:52:39

标签: c# winforms

在以下代码中,对Zoom(0.1f);Zoom(-0.1f);的两次调用有效,但我无法触发 CTRL UndoRedoManager.Undo();和UndoRedoManager.Redo();调用> + Z CTRL + Y 。我做错了什么?

public void WorkspaceKeyDown(KeyEventArgs e)
{
    if (e.Control == true)
        isCtrlPres = true;
    if (e.Shift == true)
        isShiftPres = true;
    if (e.Control == true && e.KeyCode == Keys.Z)
    {
        UndoRedoManager.Undo();
    }
    else if (e.Control == true && e.KeyCode == Keys.Y)
    {
        UndoRedoManager.Redo();
    }
    else if (e.Control == true && e.KeyCode == Keys.Oemplus)
    {
        Zoom(0.1f);
    }
    else if (e.Control == true && e.KeyCode == Keys.OemMinus)
    {
        Zoom(-0.1f);
    }

1 个答案:

答案 0 :(得分:0)

.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));