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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:16:32+00:00 2026-05-23T00:16:32+00:00

I have two comboBox cb_Brand and cb_Model on a winForm. cb_Model populates values on

  • 0

I have two comboBox cb_Brand and cb_Model on a winForm.

cb_Model populates values on brand Select.
the problem is: if we select the brand any and select the any model under that brand, cb_Model does not loose the value of previous model selected.
for example: If we select the brand Audi and model A3
and the select the Brand Ford, when I click on cb_Model to select the model, it displayed the A3 as selected model, but still other models in list are belong to ford.

my code is:

private void cb_Brand_SelectedIndexChanged(object sender, EventArgs e)
{
    // Clear Current Data
    cb_Model.Text = "";
    cb_Model.Items.Clear();

    CarModel _carmodel = new CarModel ();

    // Get Selected Car Brnad
    int CarBrandID = _carmodel .GetCarBrandID(cb_Brand.Text);

    //Enable choice of Model
    SortedList<int, Model> colM;

    colM = Model.ReadModel(CarBrandID);

    cb_Model.DisplayMember = "ModelText";
    foreach (Model objM in colM.Values)
    {
        cb_Model.Items.Add(objM);
    }
}

Any Idea Please..
Thanks


unable to find the reason but sorted out with a temp fix:

private void cb_Model_Click(object sender, EventArgs e)
{
    cb_Model.Text = "";
}

Thanks a lot guys
cheers

  • 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-23T00:16:33+00:00Added an answer on May 23, 2026 at 12:16 am

    Instead of adding the items manually like this:

    foreach (Model objM in colM.Values)
    {
        cb_Model.Items.Add(objM);
    }
    

    Let .NET take care of it for you and replace it with this:

    cb_Model.DataSource = colMValues;
    

    Which will bind the data to the list and refreshes the comboboxes items automatcially when a data source is set.

    You will also not need these lines anymore:

    // Clear Current Data
    cb_Model.Text = "";
    cb_Model.Items.Clear();
    

    Have a read of this for more info on binding lists (and other data sources) to ComboBoxes:

    How to: Bind a Windows Forms ComboBox or ListBox Control to Data (MSDN)

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

Sidebar

Related Questions

I have a little problem. At my application Im always building two linked combobox
I have two applications written in Java that communicate with each other using XML
I have two combobox controls. If i change combobox A then I am reading
On a form, I have two combobox wich have the same DataSource (their elements
How far is the code for best functionallity? I have two ComboBox, so the
I have a ListView that contains two types of objects, single and multiple. The
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two elements: <input a> <input b onclick=...> When b is clicked, I
I have two identical tables and need to copy rows from table to another.

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.