我添加按鍵事件錯誤的嘗試在C#中做按鍵下壓事件時
private void listView_KeyPress(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
DeleteContact();
}
}
框架自動爲其創建的類:
this.listView.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.listView_KeyPress);
當編譯我得到一個錯誤System.Windows.Forms.KeyPressEventHandler(this.listView_KeyPress)
No overload for 'listView_KeyPress' matches delegate 'System.Windows.Forms.KeyPressEventHandler' D:\...\MainForm.Designer.cs
我將不勝感激任何有用的答案,謝謝。
您是否在您擁有的類中定義了方法listView_KeyPress:this.listView.KeyPress + = .... ??? –
再次刪除。您需要KeyDown事件來識別Delete鍵。 –