[]
        
(Showing Draft Content)

IListBox

Interface IListBox

All Superinterfaces:
ICellLinkControl, ICellLinkControlT<Integer>, IControl, IControlT<IListBox>, ISelector, ISelectorT<ListBoxItem,IListBoxItemList>

public interface IListBox extends IControlT<IListBox>, ISelectorT<ListBoxItem,IListBoxItemList>
Represents a list box control.

A list box displays a collection of ListBoxItem objects and lets users select one or more items, depending on the configured SelectionMode. Use IControlCollection.addListBox(double,double,double,double) to add a list box to a worksheet, then populate it through ISelectorT.getItems() and configure its selection behavior with setSelectionMode(SelectionMode).


 IListBox listBox = worksheet.getControls().addListBox(50, 100, 120, 80);
 listBox.getItems().add(new ListBoxItem("Apple"));
 listBox.getItems().add(new ListBoxItem("Orange"));
 listBox.setSelectionMode(SelectionMode.Extended);
 IListBoxItemCollection selectedItems = listBox.getSelectedItems();
 
  • Method Details

    • getSelectionMode

      SelectionMode getSelectionMode()
      Gets the selection mode.

      Returns the current SelectionMode that controls whether the list box allows single selection or multiple selection.

      
       IListBox listBox = worksheet.getControls().addListBox(50, 100, 120, 80);
       listBox.getItems().add(new ListBoxItem("Apple"));
       listBox.setSelectionMode(SelectionMode.Extended);
       SelectionMode mode = listBox.getSelectionMode();
       
      Returns:
      The current selection mode.
    • setSelectionMode

      void setSelectionMode(SelectionMode value)
      Sets the selection mode.

      Use this method to control whether the list box allows single selection, multiple selection, or extended multiple selection through SelectionMode. Changing between single-selection and multi-selection modes resets the current selection state as needed to match the new mode.

      
       IListBox listBox = worksheet.getControls().addListBox(50, 100, 120, 80);
       listBox.getItems().add(new ListBoxItem("Apple"));
       listBox.getItems().add(new ListBoxItem("Orange"));
       listBox.setSelectionMode(SelectionMode.Extended);
       IListBoxItemCollection selectedItems = listBox.getSelectedItems();
       
      Parameters:
      value - The selection mode to apply.
    • getSelectedItems

      IListBoxItemCollection getSelectedItems()
      Gets the currently selected items.

      Returns the collection that represents the current selection in the list box. When the selection mode allows multiple selection, the collection can contain more than one item.

      
       IListBox listBox = worksheet.getControls().addListBox(20, 20, 120, 60);
       listBox.getItems().add(new ListBoxItem("North"));
       listBox.getItems().add(new ListBoxItem("South"));
       listBox.setSelectionMode(SelectionMode.Extended);
       listBox.getSelectedItems().add(listBox.getItems().get(0));
       IListBoxItemCollection selectedItems = listBox.getSelectedItems();
       
      Returns:
      The collection of currently selected items.