Hi,
I need a little help with listboxes. I have created a listbox in WPF, and added items with the listbox1.items.Add(...) method from the c# code. The items appear alright, but I can't select them one-by-one, selection is all messed up. Seems that these items have the same index. How can I get listbox.items.add to work correctly?
Thank you in advance
V
Loading

Stefan138 reputationPosted Mar 27, 2009, 1:54 PM EDT
Viktor P7 reputationPosted Mar 27, 2009, 2:00 PM EDT
{
listBox1.Items.Add("item")
}
I press the button several times, and then try to select the items.
Stefan138 reputationPosted Mar 27, 2009, 2:12 PM EDT
Viktor P7 reputationPosted Mar 27, 2009, 2:37 PM EDT
I've also found that all the items added from c# have the same index property.
amit ramdeo4 reputationPosted Mar 27, 2009, 10:40 PM EDT
hi there ..
i is happening as you are trying to add the same object again and again.
just try to add different one to the list box like
decalre one variable i and increment in each click. then add the variable along with the name and check
i++;
listBox1.Items.Add("Amit"+i);
Viktor P7 reputationPosted Mar 28, 2009, 6:51 AM EDT
Thanks, anyways!