[]
        
(Showing Draft Content)

ISelector

Interface ISelector

All Superinterfaces:
ICellLinkControl, ICellLinkControlT<Integer>, IControl
All Known Subinterfaces:
IDropDown, IListBox, ISelectorT<T,TCollection>

public interface ISelector extends ICellLinkControlT<Integer>
Represents a selector control that lets a user choose an item from a list.

This interface provides the common selection members for controls such as IDropDown and IListBox. A selector can populate its choices from ISelectorT.getItems() or bind them to a worksheet range through getItemsSourceRange() and setItemsSourceRange(IRange). When an items source range is set, the items collection is read-only. Through the inherited cell-link members, the current selection value is exposed as getSelectedIndex() plus 1.


 ISelector selector = worksheet.getControls().addDropDown(20, 20, 120, 20);
 worksheet.getRange("A1:A3").setValue(new Object[][] {{"Pending"}, {"Approved"}, {"Rejected"}});
 selector.setItemsSourceRange(worksheet.getRange("A1:A3"));
 selector.setSelectedIndex(1);
 
  • Method Details

    • getItemsSourceRange

      IRange getItemsSourceRange()
      Gets the items source of this control.

      This property can't be used if items were added to ISelectorT.getItems(). When an items source range is set, the control reads its items from that worksheet range instead of from the items collection.

      This property doesn't handle #REF! errors. #REF! will be treated as an empty collection.

      
       ISelector selector = worksheet.getControls().addDropDown(20, 20, 120, 20);
       worksheet.getRange("A1:A3").setValue(new Object[][] {{"Pending"}, {"Approved"}, {"Rejected"}});
       selector.setItemsSourceRange(worksheet.getRange("A1:A3"));
       IRange range = selector.getItemsSourceRange();
       
      Returns:
      The range that provides the items for this control, or null if no items source range is set.
    • setItemsSourceRange

      void setItemsSourceRange(IRange value)
      Sets the items source of this control.

      This property can't be used if items were added to ISelectorT.getItems(). When an items source range is set, the control reads its items from that worksheet range instead of from the items collection. Passing null clears the current items source range.

      This property doesn't handle #REF! errors. #REF! will be treated as an empty collection.

      
       ISelector selector = worksheet.getControls().addDropDown(20, 20, 120, 20);
       worksheet.getRange("A1:A3").setValue(new Object[][] {{"Pending"}, {"Approved"}, {"Rejected"}});
       selector.setItemsSourceRange(worksheet.getRange("A1:A3"));
       
      Parameters:
      value - The worksheet range that provides the items for this control, or null to clear the current items source range.
    • getSelectedIndex

      int getSelectedIndex()
      Gets the selected index of this control.

      Returns the zero-based index of the currently selected item. Returns -1 if no item is selected.

      
       ISelector selector = worksheet.getControls().addDropDown(20, 20, 120, 20);
       worksheet.getRange("A1:A3").setValue(new Object[][] {{"Pending"}, {"Approved"}, {"Rejected"}});
       selector.setItemsSourceRange(worksheet.getRange("A1:A3"));
       selector.setSelectedIndex(1);
       int selectedIndex = selector.getSelectedIndex();
       
      Returns:
      The zero-based selected index of this control, or -1 if no item is selected.
      API Note:
      Not fully supported by the *.ssjson format. The index could cause IndexOutOfBoundsException if items are lost.
    • setSelectedIndex

      void setSelectedIndex(int value)
      Sets the selected index of this control.

      Sets the zero-based index of the currently selected item. Sets -1 if no item is selected.

      
       ISelector selector = worksheet.getControls().addDropDown(20, 20, 120, 20);
       worksheet.getRange("A1:A3").setValue(new Object[][] {{"Pending"}, {"Approved"}, {"Rejected"}});
       selector.setItemsSourceRange(worksheet.getRange("A1:A3"));
       selector.setSelectedIndex(1);
       
      Parameters:
      value - The zero-based selected index of this control, or -1 if no item is selected.
      API Note:
      Not fully supported by the *.ssjson format. The index could cause IndexOutOfBoundsException if items are lost.