I have listbox1 that is displayed by the application. In one method I create listBox2 and assign it to listBox1 by simple listBox1=listBox2. The WinForms however still display items from listBox1 however it now points (I mean the value of reference type listBox1) to listBox2. Why is that?
Share
You’re only changing the reference to list box. However the visual tree (layout) remains the same – try to remove the first list box from its parent’
Controlscollection and add the 2nd list box to this collection.For more precise replacement, find the index of
listBox1in theControlscollection.