gpt4 book ai didi

c# - 处理开关 block 内的多个键

转载 作者:行者123 更新时间:2023-12-02 01:50:00 25 4
gpt4 key购买 nike

我正在开发一个 Windows 窗体应用程序,每当用户按下 F12 和 ctrl 键的组合时,我都会尝试隐藏面板,但我收到错误运算符“&&”无法应用于“Keys”类型的操作数和“ key ”。感谢您抽出时间。

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
//method to assign keys
switch (e.KeyCode)
{
case Keys.Down:
SendKeys.Send("{Tab}");
e.Handled = true;
break;

case (Keys.Control && Keys.F12): **// error here**
this.panel3.Hide();
default:
break;
}
}

最佳答案

如果您想在Ctrl + F12组合上Hide(),您应该检查e.Modifiers:

...

case (Keys.F12): // On F12
if (e.Modifiers == Keys.Control) { // On Ctrl + F12
this.panel3.Hide();
}

...

关于c# - 处理开关 block 内的多个键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70436937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com