ComponentOne List for WinForms
In This Topic
    List Items
    In This Topic

    A List can have any number of list items. You can perform different operations on these list items as per your requirement. Let us explore how to perform some basic operations on list items.

    Add Items

    You can add items to the list using AddItem method of the C1List class. The AddItem method allows you to populate individual rows within the list. Please note that the default AddItem separator is semicolon ";". However, you can choose a custom separator by setting AddItemSeparator property of the C1List class.

    Use the following code snippet to add rows to the list.

    C#
    Copy Code
    c1List1.AddItem("Smith; Elm St.;5887552");
    c1List1.AddItem("John; Oak St.;6336958");
    c1List1.AddItem("Aron; Silver Canoe Way;5869658");
    

    Insert Items

    You can use InsertItem method of the C1List class to insert an item at the specified position. The following code demonstrates how to insert the second row in the List control.

    C#
    Copy Code
    c1List1.InsertItem("Joseph; Loch Ness Road ;7856247", 1);
    

    Remove Item

    The RemoveItem method can be used to remove rows from the list by specifying the index of the row that you want to delete. The following code demonstrates how to remove the selected row from the list control:

    C#
    Copy Code
    c1List1.RemoveItem(this.c1List1.SelectedIndex);
    

    Clear Items

    The ClearItems method removes all items from the list population. The following code removes the entire population from the list control:

    C#
    Copy Code
    c1List1.ClearItems();