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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:34:55+00:00 2026-06-17T19:34:55+00:00

I have a ComboBox with the following code: private void comboBox1_TextChanged(object sender, EventArgs e)

  • 0

I have a ComboBox with the following code:

private void comboBox1_TextChanged(object sender, EventArgs e)
{
    using (var service = WebServiceHelper.GetCoreService())
    {
        string physicianXml = service.SearchPhysicians(SessionInfo.Current.ClientCode, SessionInfo.Current.MachineName,
                                    SessionInfo.Current.Username, comboBox1.Text);

        var physicians = PhysicianItemList.FromXml(physicianXml);

        AutoCompleteStringCollection autoCompleteStringCollection = new AutoCompleteStringCollection();
        foreach (var physician in physicians.Items)
        {
            autoCompleteStringCollection.Add(physician.LastName + ", " + physician.FirstName);
        }

        comboBox1.AutoCompleteCustomSource = autoCompleteStringCollection;
        comboBox1.Select(comboBox1.Text.Length, 0);
    }
}

Basically, a user types the first few characters of a physician’s name and it should populate the auto-complete list with the top 100 matching records. It works great, but I need to associate it back to a key (either the PK from the table, or the Physician’s NPI number). It seems the AutoCompleteStringCollection doesn’t support keys. Can anyone suggest a way of doing this? There are approximately 7 million records in the table, so I don’t want to prepopulate the ComboBox.

Thanks

  • 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-06-17T19:34:56+00:00Added an answer on June 17, 2026 at 7:34 pm

    When you build your AutoCompleteStringCollection, build a Dictionary<String, int> for the name, id pairs as well. Then use some event (textbox validation or user submit/save click) to lookup and set the id. You could store the dictionary on the textbox Tag.

    Edit

    For some reason I thought you were working with a textbox control. Forget about the AutoCompleteStringCollection and just build a Dictionary<String, int>. For the combobox set your autocompletesource to ListItems, set the combobox display name and value and set the datasource to the dictionary.

    combobox.DisplayMember = "key";
    combobox.ValueMember = "value";
    combobox.AutocompleteSource = AutocompleteSource.ListItems;
    combobox.DataSource = myDictionary;
    

    However you should only populate the datasource and autocomplete once when the user enters n characters in the combobox, otherwise it gets buggy. I tried to use this for a dynamic autocomplete once (eg the list clears if the user clear the text and retypes), but I had to forget about the combobox and use a hybrid textbox listbox approach much like this user

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

Sidebar

Related Questions

I have following piece of code: private void nameTextBox_Leave(object sender, EventArgs e) { var
I have a combobox that is bound to an enum using the following code:
i have the following code to fill two comboboxes using one dataset: Private Sub
I have a following XAML: <ComboBox Name=groupComboBox ItemsSource={Binding Path=MyServiceMap.Groups} DisplayMemberPath={Binding Name}/> In the code
I have the following code : public partial class ModificarAlimento : Form { private
I have the following code that I'm trying to use to populate a ComboBox,
I have the following code: $(document).ready(function () { $(#comboSubsidiary).combobox({ selected: function (event, ui) {
I have the following code in VS2010 Ultimate: class MyComboBox : System.Windows.Forms.ComboBox { public
I have the following collection which i would like to bind to a combobox:
I have the following code so that I can search directories to find files.

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.