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

  • SEARCH
  • Home
  • 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

Does .NET have some type of built in function that allows filtering on Gridviews?
I am using Ext.Net I have a form with a ComboBox which I have
In my asp.net application I have a form where a user can pick a
In .NET 3.5, I have a Winform with a combobox in it. The datya
I have a Combobox control on my form (WinForms, .NET 3.5), and its DropDownStyle
I am using Ext.Net 1.3 with ASP.NET 4.0 application. I have few Ext ComboBox
This is what I'm talking about: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx basically I want to have a drop
C#, .NET 4.0, VS2010. New to WPF. I have a ComboBox on my MainWindow.
I have control (implemented C#, .Net 2.0) that inherits from combobox. It has filtering
WinForms, .NET 3.5 I have a ComboBox that needs to display a growing list

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.