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 7011991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:11:53+00:00 2026-05-27T22:11:53+00:00

I have a listbox which displays the contents of an array. The array is

  • 0

I have a listbox which displays the contents of an array. The array is populated with a list of results when my “go” button is pressed.

The go button is set as the AcceptButton on the form properties so pressing the Enter key anywhere in the focus of the form re-runs the go button process.

Double clicking on a result from the array within the listbox works fine using below:

void ListBox1_DoubleClick(object sender, EventArgs e) {}

I would like to be able to use my arrow keys and enter keys to select and run an event without having to double click on the line within the listbox. (however go button runs each time instead)

Basically open the form, type search string, press enter to run go button, use up and down arrows then press enter on selection to run same event as double click above. Will need to change focus after each bit.

  • 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. Editorial Team
    Editorial Team
    2026-05-27T22:11:53+00:00Added an answer on May 27, 2026 at 10:11 pm

    You can handle the KeyDown events for the controls you want to override. For example,

    private void textBox1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            //execute go button method
            GoButtonMethod();
            //or if it's an event handler (should be a method)
            GoButton_Click(null,null);
        }
    
    }
    

    That will perform the search. You can then focus your listbox

    myListBox.Focus();
    //you might need to select one value to allow arrow keys
    myListBox.SelectedIndex = 0;
    

    You can handle the Enter button in the ListBox the same way as the TextBox above and call the DoubleClick event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListBox which displays items of variable height. I want to show
I have a WPF listbox which displays messages. It contains an avatar on the
I have a ListBox which is populated from a collection of ViewModels, which uses
I have a listbox which acts as a list of items. If you click
So, I have a ListBox which is bound to a list of business objects,
I have a ListBox which displays the collection of MyObjects. The collection is in
I have a ListBox which happily displays data using a code-behind MVVM object. However,
I have a ListBox which I am using to display the results of various
I have WPF ListBox which is bound to a ObservableCollection, when the collection changes,
I have this ListBox which is bound to an ObservableCollection. Each object in the

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.