ListBox Remove Items

3 posts, 1 answers
  1. Mathew
    Mathew avatar
    20 posts
    Member since:
    Nov 2010

    Posted 23 Feb 2011 Link to this post

    Can someone post how to remove all items from a RadListBox?  This below code in the cs file doesn't work.

     

    foreach (RadListBoxItem item in RadListBox1.Items)

     

     {

     

        item.Remove();

     

        //RadListBox1.Items.Remove(item);

    }

    My (hopefully temporary) workaround for this is that I create an empty DataSet and rebind that to the RadListBox.

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Feb 2011 Link to this post

    Hello Mathew,

    Try the following code to achieve the same.
    C#:
    for (int i = RadListBox1.Items.Count-1; i >= 0; i--)
          {
              RadListBox1.Items.Remove(RadListBox1.Items[i]);
          }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mathew
    Mathew avatar
    20 posts
    Member since:
    Nov 2010

    Posted 25 Feb 2011 Link to this post

    That works.  Thanks Shinu!
Back to Top