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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:24:36+00:00 2026-06-05T09:24:36+00:00

I am creating a C# application to user for my brother in his store.

  • 0

I am creating a C# application to user for my brother in his store.

I have a SQL Server database that stores all sold items, The items are added from the application.

When the user enters text in the ‘CustomerName’ field in the application, i want it to do a DB call and check for any previous sales with the same customer name (or what has been typed of the name so far) and fill in the text box will the name.

The problem i am having is: if there is a customer called John and another called Joe and i need to select John, if i type in J in the box, it will just select Joe, and then return the text cursor to the beginning of the text box which is rather annoying and inconvenient.

The ideal solution would be is if i type J in the textbox, a dropdown box just below the text box would appear displaying all the Customers with J, allowing the user to select a customer and then filling in the textbox with the value. If i then type Jo, all the records for Jo would appear in the dropdown etc.

The coding part shouldn’t be a problem (hopefully), i just wanted to know the best way to approach this.

  • 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-05T09:24:38+00:00Added an answer on June 5, 2026 at 9:24 am

    First add/change these properties in your textbox

    textBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
    textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
    

    then you could use this method to get a List of customer names that start with your prefix.

    public List<string> GetCustomerInfo(string custName)
    {
        List<string> result = new List<string>();
        string sql = "Select Name from Customers Where Name like @partName";
        using(SqlConnection con = GetConnection())
        using(SqlCommand cmd = new SqlCommand(sql, con))
        {
             con.Open();
             cmd.Parameters.AddWithValue("@partName", custName + "%"); 
             using(SqlDataReader r = cmd.ExecuteReader())
             {
                  while(r.Read()) 
                  {
                      if(!r.IsDbNull(0)) 
                          result.Add(r.GetString(0)); 
                  }
             }
        } 
        return result; 
    } 
    

    As a safeguard I will check if the text typed in your combobox is at least three chars

    if(textBox1.Text.Length >= 3)
        textBox1.AutoCompleteCustomSource = GetCustomerInfo(textBox1.Text);
    else
        textBox1.AutoCompleteCustomSource = null;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a application that store basic database connection info like host,user, password
I am interested in creating a simple web application that will take in user
I am creating an application that highlights user messages from a stream based on
I am currently creating an application that has a user, the user can follow
I'm creating an application that will tell a user how far away a large
I'm currently facing a need of creating user frontend application to database with dozens
I have the following requirement for creating a user profile in my application: User
I'm creating an application that allows the user to add their own UISwitch and
I'm creating an application that allows a user to create widgets. There are several
i'm Creating an application that will be working off a User table, the user

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.