Strange listbox datasource behaviour

Mar 6 2015 10:34 AM
Hi,
 
 When I set the DataSource property for two listboxes to the same list (List<MyClass>) and I select an item in one listbox, this is automatically selected in the second listbox too. That is pretty weird behaviour in my opinion. Has anyone seen that before? Is it a know bug in Visual Studio Professional 2012 (11.0.61030.00 update 4) / .NET framework 4.5.50709 ?
 
Thanx,
 
André
 
example code (in form with two listboxes, MyClass just some class):
List<MyClass> classes = new List<MyClass >(10);
for (int k = 1; k < 6; k++)
{
   MyClass d = new MyClass(k.ToString(), String.Format("name-{0}", k));
   classes.Add(d);
}
listBox1.DataSource = classes;
listBox2.DataSource = classes;

 

Answers (3)