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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:18:11+00:00 2026-05-28T03:18:11+00:00

I am using a combobox without the dropdown to accept text input only. On

  • 0

I am using a combobox without the dropdown to accept text input only. On the windows form I have an OK button which calls a function that uses the combobox.Text property.

The problem is that I want to call this function when the user types something then hits ENTER. I am trying to handle the KeyDown event (I have tried other events with much the same results) but I find that combobox.Text is null after this is fired. I want something like this to work ideally:

private void cbox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
        {
            OK(cbox.Text); 
        }
    }  

Why is combobox.Text wiped after the KeyDown event? This same problem wouldn’t happen with a Textbox right? I’m nearly desperate enough but I don’t want to replace this box on every form in the program lol… Please advise!

  • 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-28T03:18:12+00:00Added an answer on May 28, 2026 at 3:18 am

    Do you have more than one ComboBox on your form? The event is for cbox but you are getting the text result from cbo.

    I would suggest changing you code to this:

    private void cbox_KeyDown(object sender, KeyEventArgs e)
    {
         if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
         {
              string result = cbox.Text;
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple comboBox with some Value/Text items in it. I have using
using jquery I have a autocomplete text box like the combobox example on the
I'm using gtk.combo_box_new_text() to make combobox list, this uses a gtk.ListStore to store only
I need to have a function in C++/CLI which do the link between a
I was using a combobox on my search form to select whether to consult
I am using Windows Forms , and I have a combo box with the
I am using editable combobox for my application. Combobox have default behavior like If
I have been trying to load a text file into a combobox, and then
So, I have a form, which looks like this: And, as you can see,
how can you dynamically add items to a combobox using the datagridview virtual mode?

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.