Hi,

I have one form, in that one textbox & Buttons is there for Search functionality. Enter whatever in the text box, it will search from the one of the Tree View Node.

So my question is when I form is showed to user and when I press the Enter Key, it will serach the that Text in from the Tree node rather then click on that Search button ?

Every control including the form has they're own KeyPress event, which makes programming for that quite a bother. A more efficient solution would be to give the textbox first tabindex, so that when the form starts the textbox immediatley has focus. This way you only need to program the KeyPress event handler for one control

You need to have a method in the KeyDown event of the textbox like say :-

private void CallKeyDown(object sender, KeyEventArgs e)
{
    if(e.Key==Key.Return)
    {
      // Your Search Functionality
    }
}

Hope that helps :)

If you set the KeyPreview property of the Form to true, it will get to see if it wants to handle the keypress before it's passed on to whatever control has focus, so you don't need a handler for all the controls, just one for the form.