Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

Newbie Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sherri - 14 Aug 2006 15:20 GMT
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!
Nicholas Paldino [.NET/C# MVP] - 14 Aug 2006 15:29 GMT
Sherri,

   What exactly is it that you are searching?  The web?  The file system?
Something else?  Can you be more specific?

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!
sherri - 14 Aug 2006 15:51 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.