フォーム 3 を開くには alt+1 キーを追加するフォームが必要ですが、何らかの理由でデバッグしてショートカットを押すとショートカットが開きません
フォーム 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)
{
}
}
}