“KeyPress” event for WinForms textbox is missing?

后端 未结 3 1474
灰色年华
灰色年华 2021-01-18 04:01

I am trying to add an \"KeyPress\" event in a textbox (WinForm)

this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckKeys);
         


        
3条回答
  •  北恋
    北恋 (楼主)
    2021-01-18 04:59

    Have you looked at the documentation on KeyPress? It states specifically that The KeyPress event is not raised by noncharacter keys; however, the noncharacter keys do raise the KeyDown and KeyUp events. Using one of those events instead should work.

提交回复
热议问题