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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:40:23+00:00 2026-05-27T21:40:23+00:00

I have two ListBox in my winforms application, I assigne a datasource for both

  • 0

I have two ListBox in my winforms application, I assigne a datasource for both of them as follow:

private void MakeMeasurementUnits()
{
    var units = new List<MeasurementUnit>
                    {
                        new MeasurementUnit {Name = "Current", SiUnit = "A"},
                        new MeasurementUnit {Name = "Voltage", SiUnit = "V"},
                        new MeasurementUnit {Name = "Time", SiUnit = "s"},
                        new MeasurementUnit {Name = "Temprature", SiUnit = "°C"}
                    };

    lbxXunit.DataSource = units;
    lbxYunit.DataSource = units;
}

The strange thing is (or maybe because it is my first time!!), in the form when I click on items of one of these lisboxes, the same item in the second listbox gets selected as well. Is this a default behaviour? how to prevent this? If this is default behaviour, what is useful about it?

I found the quick remedy to be making two different datasources (same thing with another name)

  • 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-27T21:40:24+00:00Added an answer on May 27, 2026 at 9:40 pm

    The listbox seems to cache the binding source. This is default behavior. If you want to avoid this, the easy way is to create a copy of the list to bind to the second data source:

    lbxXunit.DataSource = units;
    lbxYunit.DataSource = units.ToList();
    

    This is useful when you have multiple views of the same data and want to synchronize the selection of these items.

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

Sidebar

Related Questions

I've a ListBox in my winforms app. I want it to have as DataSource
I have two ListBoxes, lstAvailableColors and lstSelectedColors. Between each listbox are two buttons, Add
I have an instance of ObservableCollection bound to a WPF listbox with two separate
I have a databound listbox which is actually displaying two columns of data. It
I have a vertical StackPanel with two elements: a Button and a ListBox. How
I have a WPF TabControl with two TabItems. Each TabItem contains a ListBox with
I have two asp:ListBox. The ID's are Authors and AuthorsSelected. Authors listbox is loaded
I have two classes A & B, and a listbox. I assign listBox.ItemsSource equal
I have two list boxes like show below, side by side. They both have
Assume I have a Listbox with two types of objects in it, either a

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.