我需要表单来添加键 alt+1 来打开表单 3,但是由于某种原因,当我调试并按下快捷方式时,它不会打开快捷方式
这是表格 2 中的代码段
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode == Keys.A)
{
Form3 f3 = new Form3();
f3.ShowDialog();
}
}
正如我所说,如果 ti 有帮助,它不会按预期打开表格 3,这是我在表格 2 中使用的整个代码:[更新] [未解决]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.KeyPreview = true;
this.KeyDown += new KeyEventHandler(Form1_KeyDown);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
var myForm = new Form2();
myForm.Show();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode == Keys.A)
{
Form3 f3 = new Form3();
f3.ShowDialog();
}
}
private void Form2_Load(object sender, EventArgs e)
{
}
}
}