Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 14th, 2008, 04:08 AM
Registered User
Join Date: Apr 2008
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default How to remove items from ArrayList?

I am coping contents of DataReader in to ArrayList and bind this ArrayList to dropdownlist1.Now i want to remove the item from my arraylist which has been selected by dropdownlist1,after deleting d item i want to bind the updated arraylist to the another dropdownlist and so on. My code looks like following....

item = new ArrayList();
        OracleCommand ocmd = new OracleCommand(qitem, conn);
        OracleDataReader odr = ocmd.ExecuteReader();
        if (odr.HasRows)
            while (odr.Read())
        bind_control(ddl_mainItem, item);

Now i want to delete item selected by ddl_mainItem.What can I do?
Plz help me......:)

Old April 14th, 2008, 04:34 AM
Friend of Wrox
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post

Hi Vish.

Are you working in C# 2.0? If so, its recommended to use generic Lists in rather than the non-generic ArrayList.

The following code should help:
List<string> items = new List<string>();
// populate list

// to remove...
// Get listIndex from DropDown and remove the Item.
int idx = comboBox1.SelectedIndex;
Note that you are not updating the data here!

The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://robzyc.spaces.live.com

Similar Threads
Thread Thread Starter Forum Replies Last Post
ArrayList Mogg-Way C# 2005 5 February 12th, 2008 04:05 PM
Return an arraylist Morrislgn VB.NET 2002/2003 Basics 1 March 24th, 2006 04:42 AM
Help with an arraylist crazy-nun General .NET 4 July 14th, 2005 03:32 AM
ArrayList kobystud C# 4 May 25th, 2004 02:05 PM
displaying 6 items only having 20 items Lakshmi KS VB Components 1 February 17th, 2004 10:34 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.