tags:

views:

33

answers:

1

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 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

A: 

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.

Phil Wright