adding items to array list comparing with list box items in C# windows form

Posted on 2007-09-28
Last Modified: 2013-11-26
i had a arraylist i want to add items to array list only if the items are not contained in the listbox
so iam using the array list as follows
ArrayList  aL=new ArrayList ();
if(aL.Contains( to check the items in listbox...)
Question by:kranthi4uonly
    1 Comment
    LVL 22

    Accepted Solution

    The ListBox Items property returns a collection of objects. So,
    string next = string.Empty;
    for each( object item in myListBox.Items)
       next = item as string;
       if (!al.Contains(next))


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Problem with C# 1 44
    Help with appending data from file2 to file1 using VB.NET 5 32
    Problem to event 3 25
    DataGridView 2 6
    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now