Work with multiple selected items from a ListBox

R

Ryan Ternier

I'm having an issue with a listbox.

I want to allow users to multi select items in a list box, click a button
and have them moved somewhere else.

This works fine for the the first 2 tries. However, a user also has the
ability to add these items back to the listbox (with the same value and
Text).

The new Items get moved to the bottom of the list box.

It works fine to a point, however, once I move over all items, and move 5
back, if I select all 5, it will only notice that 3 of them are
selected.though all 5 are. 2 Will be left, so when I select those 2, it will
only move 1.

Any help would be great.

here's my code:
--------------------------------------------------------------------------------


System.Collections.ArrayList arlTemp = new System.Collections.ArrayList();
foreach(ListItem li in lstAvailHeadings.Items)
{
if(li.Selected)
{
tblTemp = addSection(tblTemp,Int32.Parse(li.Value),li.Text);
arlTemp.Add(li.Value);
}
}
BindSections(tblTemp);
for(int i = 0;i<arlTemp.Count;i++)
{
for(int j = 0;j<lstAvailHeadings.Items.Count;j++)
{
if(lstAvailHeadings.Items[j].Value == arlTemp.ToString())
lstAvailHeadings.Items.Remove(lstAvailHeadings.Items[j]);
}
}
arlTemp = null;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top