
Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
>I am very new to .NET / C#. What I want to do is call a method which
> performs a search when the ENTER button on the keyboard is pressed. The
> way the application currently works is that I enter text into the
> textbox, then click the Search button.
>
> Thanks!
Thanks Nicholas!
I am calling a method that calls a web service which calls a stored
procedure and returns the search results.
I basically just want to input some text into the textbox, then click
the enter key, which will call the above method.
Thanks Again!
> Sherri,
>
[quoted text clipped - 11 lines]
> >
> > Thanks!
WhiteWizard - 14 Aug 2006 16:18 GMT
Try something like this:
private void sysTree_KeyUp(object sender, Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
//Run some method
}
}
HTH
WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
> Thanks Nicholas!
>
[quoted text clipped - 20 lines]
> > >
> > > Thanks!
Phil - 14 Aug 2006 16:34 GMT
>Thanks Nicholas!
>
[quoted text clipped - 3 lines]
>I basically just want to input some text into the textbox, then click
>the enter key, which will call the above method.
Sheri,
Assuming this is Windows Forms and not ASP.Net, one of the best ways
to do this, especially if you have *multiple* text boxes on which you
want to do this, is to set the KeyPreview property of the form to
true, then subscribe to the KeyDown event with something like this:
private void OnKeyDown(object sender, KeyEventArgs e) {
if (e.KeyCode == Keys.Return)
OnSearch(); // your method here
}
The form will get this event before any control - that's what
KeyPreview is for.
--
Phil