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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:49:57+00:00 2026-05-27T20:49:57+00:00

I am trying to use AutoComplete feature of textboxes in my winforms application. The

  • 0

I am trying to use AutoComplete feature of textboxes in my winforms application.

The textbox is used to send some GPIB/SCPI commands to an instrument. So before I get the idea of autocomplete it was working fine, but with autocomplete, the KeyPress event is no more working.

The code I wrote is this:

//AutoComplete collection
AutoCompleteStringCollection _commandHistory = new AutoCompleteStringCollection();

public Form1() //Constructor
{
    InitializeComponent();

    _commandHistory.AddRange(new string[3]{"*IDN?", "*RST", ":READ?"});
    tbCommandLine.AutoCompleteSource = AutoCompleteSource.CustomSource;
    tbCommandLine.AutoCompleteCustomSource = _commandHistory;
    tbCommandLine.AutoCompleteMode = AutoCompleteMode.Append;
}

And here is what I defined for the KeyPress event

private void tbCommandLine_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == (char)Keys.Return)
    {
        SendCommand(tbCommandLine.Text.Trim()); //Send Command
        _commandHistory.Add(tbCommandLine.Text.Trim()); //Store command in autocomple source
        tbCommandLine.Text = String.Empty; //clear textbox
    }
}

After I added the AutoComplete, if I press enter or type something that is in the source of autocomple, the text in the textbox will get hihglighted and the enter key will not do anything.

  • 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-27T20:49:58+00:00Added an answer on May 27, 2026 at 8:49 pm

    Solved by changing KeyPress to KeyDown

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

Sidebar

Related Questions

I'm trying to use JQuery's autocomplete plug-in but for some reasons Internet Explorer is
I'm trying to use jQueryUI Autocomplete to implement a site quick searching feature for
I am trying to use jQuery autocomplete on my dynamically created textboxes. this is
In my rails application I am trying to use rails3-jquery-autocomplete gem. I included the
I'm trying to use the AutoComplete feature of JQuery to update multiple fields on
I am trying to add an autocomplete feature to a textbox, the results are
I am trying to use jquery autocomplete plugin in my application. It works well
I am trying to use jQuery Autocomplete Plugin in my PHP web application. I
Trying to use autocomplete functionality of YUI, we ran into the fact that it's
I am trying to use jquery autocomplete plugin, I want it to suggest ItemCodes

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.