开发者

How to Detect Enter Key press in a text box which is used in a Custom View?

I have made a custom view in which i have used a search box which is a text box to search specific directory.When we press Enter key on the search box i search the directory and if开发者_JAVA百科 found then refresh my custom browser to dispaly the new diretories content. but the problem is when i am in modal dialog then i could not detect the Enter key press event in the search box though i could detect the others key press event. When I press the Enter key it just change its focus to the windows Edit control and it does not execute any event like KeyPress/KeyDown etc.

Any suggestions


By default the Enter key is ignored by the TextBox when it is a single line control, as there is no need for it to have any response to an Enter key event. To overcome this you need to create a new class that derives from the TextBox and override the IsInputKey method. Inside here check if it is the Enter key and return True. This means the the key will be sent to the control because the control wants to process it. Then you can KeyDown for the TextBox as expected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜