1

我在 Visual Studio 2008(框架 3.5)中工作,我正在尝试将快捷方式(例如Shift+
D)添加到 menuStrip(正好添加到 menuStrip 中的 toolStrip),但我不能。我得到错误:

“参数 'value' (65604) 的值对于 Enum 类型无效Keys

参数名称:值”。它只显示Shift. 和,Ctrl没关系Alt。即使我尝试了Ctrl++ ,它也可以工作,但不能只使用和字母。ShiftDShift

4

3 回答 3

3

您不能使用 shift 和字母、数字或其他字符作为快捷键,因为 shift 键用作修饰符A——当您真正的意思是shift+时,它就像打字一样A

编辑:我在说明它的文档中没有找到任何内容,但在这个问题中,它表明您只能使用ctrlalt与字母或数字组合使用。不过,您当然可以与另一个键一起使用或任意组合shift使用ctrlalt

于 2011-01-20T09:43:52.913 回答
0

The shift key is a modifier key on a keyboard, used to type capital letters and other alternate "upper" characters. It can only be used for shortcuts in conjunction with keys which do not have any alternate usages.

于 2011-01-20T09:53:40.070 回答
0

你可以覆盖它。它可以让您Shift与其他键一起使用,例如Ctrl+ Shift+TabCtrl+ tabn 等。我最终遇到了同样的问题,这就是我解决问题的方法:

public class ExtendedTabControl: TabControl
{
    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        if (keyData == (Keys.Control | Keys.Tab))
        {
            // Write custom logic here
            return true;
        }
        if (keyData == (Keys.Control | Keys.Shift | Keys.Tab))
        {
            // Write custom logic here
            return true;
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }
}

我希望它有帮助

于 2015-05-16T13:02:55.583 回答