Press enter in textbox to and execute button command

前端 未结 10 687
时光取名叫无心
时光取名叫无心 2021-01-30 13:40

I want to execute the code behind my Search Button by pressing Enter. I have the Accept Button property to my search button. However, when i place my button as NOT vi

10条回答
  •  囚心锁ツ
    2021-01-30 13:58

    There are some cases, when textbox will not handle enter key. I think it may be when you have accept button set on form. In that case, instead of KeyDown event you should use textbox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)

提交回复
热议问题