8
Nút Escape để đóng biểu mẫu Windows Forms trong C #
Tôi đã thử những cách sau: private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if ((Keys) e.KeyValue == Keys.Escape) this.Close(); } Nhưng nó không hoạt động. Sau đó, tôi đã thử điều này: protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (e.KeyCode == Keys.Escape) this.Close(); } Và vẫn không có gì …