Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 85021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:01:25+00:00 2026-05-10T22:01:25+00:00

In VB.NET, I have a Combobox on a WinForm form. The form allows the

  • 0

In VB.NET, I have a Combobox on a WinForm form. The form allows the user to type in a query to be searched. When the user hits the Enter key, a query is performed against the database and the results are returned as a DataTable. The DataTable is then bound to the Combobox and the user can select the option that they are looking for.

For the most part, this is working great. However, we’ve discovered that the code is executing multiple times. If I write my query out and hit the Enter key ONCE, I can step through the code TWO or THREE times. I don’t want to send the same query to the database multiple times if I do not have to. Any ideas or suggestions why the code would be executing multiple times?

Here is the code in question. The Combobox and Function names have been changed to protect the innocent. 🙂

Private Sub cbx_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cbx.KeyDown      Me.Cursor = Cursors.IBeam     If e.KeyData = Keys.Enter Then         Me.Cursor = Cursors.WaitCursor         PerformSearch()         Me.Cursor = Cursors.Default     End If     Me.Cursor = Cursors.Default  End Sub 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:01:26+00:00Added an answer on May 10, 2026 at 10:01 pm

    Ironically, adding cbx.Focus() after the search has been performed fixed the problem. Here is the solution.

    Private Sub cbx_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cbx.KeyDown      Me.Cursor = Cursors.IBeam     If e.KeyData = Keys.Enter Then         Me.Cursor = Cursors.WaitCursor         PerformSearch()         cbx.Focus()         Me.Cursor = Cursors.Default     End If     Me.Cursor = Cursors.Default  End Sub 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In .NET 3.5, I have a Winform with a combobox in it. The datya
Why databinding TwoWay don't work on the text property of a combobox in .net
Currently we have a makeshift combobox which is comprised of a textbox, an arrow
I have a WPF (.NET 3.5) control which renders about 20000 rectangles. This MyControl
I have an ASP.NET project that uses XML Serialization for the main operation for
I have just downloaded Obout.com suite controls for ASP.NET 3.5 and 4.0. I made
I have a project that interacts with a database through ADO.net Data Services. The
I have an app that I wrote using C# .NET 4.0 in Visual Studio
I am very new to ASP.NET. I have a an ASP.NET page with an
I am building a WinForms Application in C# .NET The WinForms Application has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.