[]
        
(Showing Draft Content)

IItemList

Interface IItemList

All Superinterfaces:
IItemCollection<T>, Iterable<T>
All Known Subinterfaces:
IDropDownItemList, IListBoxItemList

public interface IItemList<T> extends IItemCollection<T>
Holds the list of items that constitute the content of an ISelector.

This interface extends IItemCollection with zero-based indexed access and update operations, and also supports locating, inserting, and removing items by index. It is typically obtained from a selector control such as a drop-down or list box through ISelectorT.getItems().


 IDropDown dropDown = worksheet.getControls().addDropDown(20, 20, 120, 24);
 IItemList<DropDownItem> items = dropDown.getItems();
 items.add(new DropDownItem("Low"));
 items.add(new DropDownItem("High"));
 items.set(1, new DropDownItem("Medium"));
 
  • Method Summary

    Modifier and Type
    Method
    Description
    get(int index)
    Gets the item at the given zero-based index.
    int
    indexOf(T item)
    Returns the index in this collection where the specified item is located.
    void
    insert(int index, T item)
    Inserts an element into the collection at the specified index.
    void
    removeAt(int index)
    Removes the element at the specified index of the collection.
    void
    set(int index, T value)
    Sets the item at the given zero-based index.

    Methods inherited from interface com.grapecity.documents.excel.forms.IItemCollection

    add, clear, contains, getCount, remove

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • get

      T get(int index)
      Gets the item at the given zero-based index.

      Use this method to retrieve an item from an IItemList by position. The returned object is the item stored at the specified index in the collection.

      
       IDropDown dropDown = worksheet.getControls().addDropDown(20, 20, 120, 20);
       dropDown.getItems().add(new DropDownItem("Low"));
       dropDown.getItems().add(new DropDownItem("High"));
       DropDownItem item = dropDown.getItems().get(0);
       
      Parameters:
      index - The zero-based index of the item.
      Returns:
      The object retrieved.
      Throws:
      IndexOutOfBoundsException - if index is less than 0 or greater than or equal to the number of items in the collection.
    • set

      void set(int index, T value)
      Sets the item at the given zero-based index.

      Use this method to replace the existing item stored at the specified position in the collection.

      
       IDropDown dropDown = worksheet.getControls().addDropDown(20, 20, 120, 20);
       IItemList<DropDownItem> items = dropDown.getItems();
       items.add(new DropDownItem("Low"));
       items.add(new DropDownItem("High"));
       items.set(1, new DropDownItem("Medium"));
       
      Parameters:
      index - The zero-based index of the item.
      value - The object is being set to the specified index.
      Throws:
      IndexOutOfBoundsException - if index is less than 0 or greater than or equal to the number of items in the collection.
      IllegalStateException - if the collection is read-only.
    • indexOf

      int indexOf(T item)
      Returns the index in this collection where the specified item is located.

      The returned index is zero-based.

      
       IDropDown dropDown = worksheet.getControls().addDropDown(20, 20, 120, 20);
       IItemList<DropDownItem> items = dropDown.getItems();
       items.add(new DropDownItem("Low"));
       items.add(new DropDownItem("High"));
       int index = items.indexOf(items.get(1));
       
      Parameters:
      item - The object to look for in the collection.
      Returns:
      The index of the item in the collection, or -1 if the item does not exist in the collection.
    • insert

      void insert(int index, T item)
      Inserts an element into the collection at the specified index.

      Use this method to add an item at a zero-based position in an IItemList. The inserted item is placed before the element currently at index, and the following items are shifted to the next positions.

      
       IDropDown dropDown = worksheet.getControls().addDropDown(20, 20, 120, 20);
       IItemList<DropDownItem> items = dropDown.getItems();
       items.add(new DropDownItem("Low"));
       items.add(new DropDownItem("High"));
       items.insert(1, new DropDownItem("Medium"));
       
      Parameters:
      index - The zero-based index at which to insert the item.
      item - The item to insert. Must not be null.
      Throws:
      IndexOutOfBoundsException - if index is less than 0 or greater than the number of items in the collection.
      NullPointerException - if item is null.
      IllegalStateException - if the collection is read-only.
    • removeAt

      void removeAt(int index)
      Removes the element at the specified index of the collection.

      Use this method to remove an item from an IItemList by its zero-based position.

      
       IDropDown dropDown = worksheet.getControls().addDropDown(20, 20, 120, 20);
       IItemList<DropDownItem> items = dropDown.getItems();
       items.add(new DropDownItem("Low"));
       items.add(new DropDownItem("High"));
       items.removeAt(0);
       
      Parameters:
      index - The zero-based index of the element to remove.
      Throws:
      IndexOutOfBoundsException - if index is less than 0 or greater than or equal to the number of items in the collection.
      IllegalStateException - if the collection is read-only.