c# - 为什么 KeyDown CTRL+KEY 不起作用?

标签 c# winforms

在下面的代码中,对 Zoom(0.1f);Zoom(-0.1f); 的两次调用有效,但我无法触发这两个 UndoRedoManager.Undo();UndoRedoManager.Redo(); 调用 CTRL+ZCTRL+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);
    }

最佳答案

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

关于c# - 为什么 KeyDown CTRL+KEY 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6101549/

相关文章:

wpf - 我可以在 VS2008 中开发也可以在 Mac 上运行的桌面应用程序吗?什么方法?

c# - 如何隐藏窗体而不是关闭它

C# 使用 WinForms 应用程序测试 WinService。应用程序配置不会更改值

c# - __c# 中的 fastcall 约定

c# - 如何将服务堆栈 4 与 asp.net MVC 4 并行安装?

c# - 类返回的默认值

c# - 是否可以在没有 MSBuild 的情况下编译 C# 项目?

c# - 是否可以在不将原始阅读器向前移动的情况下创建 TextReader 的副本?

c# - 绑定(bind)到 WinForms 中的命令

c# - 用鼠标拖动无边框窗体