Documentation for Win32lib v0.60.6
Table of Contents

List Control

These are routines that let you inspect and alter attributes of controls with lists


This includes Combo, DropDownList, List, SimpleCombo, SortedCombo, SortedList.

The first item in a list is 1, not 0. This makes it consistant with Euphoria's indexing method, but can be a bit confusing if you are used to working with zero-based arrays.

  • proc addItem( integer control, sequence text )    Add text to the end of control's list.
  • func deleteItem( list, position )    Delete item from list's list at position .
  • proc eraseItems( list )    Remove all items from list.
  • func findItem( integer list, sequence text, integer startpos )    Locates text in the list, starting from index startpos
  • func getCount( list )    Get the count of items in list ( List of Combo )
  • func getIndex( list )   Get the index of the selected item(s), or cursor position in an edit control.
  • func getItem( integer list, integer index )    Return the text of item at index in list.
  • func getMultIndices( id )   Get indices of multiple selections in a multi-selection list
  • func getMultItems( id )   Get text of multiple selections in a multi-selection list
  • func insertItem( integer list, sequence text, integer position )    Insert text into list at position.
  • proc setIndex( atom list, object index )    Set the selected item on the list to index.
  • func setListHScroll(integer id)   Recalculates the size of a horizontal scroll bar on a listbox.
  • proc setSelection( atom list, object index )    An alias for setIndex
  • proc setTabs( id, tabs )    Set/change tab stops in a List or SortedList Control.
  • const w32AllItems   This signifies that all items are to be deleted.

    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    addItem
    ( integer control, sequence text )

    Add text to the end of control's list.

    Category: List Control

    see also: insertItem()

    Example:

              -- add "Apples" to TheList
               addItem( TheList, "Apples" )
    

    -- add fruit list to TheList addItem( TheList, {"Oranges", "Pears", "Bananas", "Mangoes" })

    addItem is also used to add items to ComboBoxEx controls by packing several params into text. Example:

              -- add "Apples" to TheListEx with unselected image
              -- i1 and selected image i2 where, i1 and i2
               -- were values returned from addIcon()
               addItem( TheListEx, {"Apples", i1, i2})
               addItem( TheListEx, {
                                    {"Oranges", i3, i2},
                                    {"Pears",   i4, i2},
                                    {"Bananas", i5, i2},
                                    {"Mangoes", i6, i2}
                                   })
    

    See also Image Lists for details on using images

    See Also: deleteItem, eraseItems, findItem, getCount, getIndex, getItem, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    deleteItem
    ( list, position )

    Delete item from list's list at position .

    Returns: ATOM: 0 indicates failure.

    Category: List Control

    The position starts at 1.

    Example:

              -- delete item 2 from the list
               deleteItem( TheList, 2 )
    

    deleteItem() also works with list view and tree view controls. position should be the item id returned when the item was created. To delete all items in a list view or tree view, position should be -1.

    See Also: addItem, eraseItems, findItem, getCount, getIndex, getItem, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    eraseItems
    ( list )

    Remove all items from list.

    Category: List Control

    Example:

              -- erase items from TheList
               eraseItems( TheList )
    
    Also works with ComboBox ListView and TreeView controls.

    See Also: addItem, deleteItem, findItem, getCount, getIndex, getItem, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    findItem
    ( integer list, sequence text, integer startpos )

    Locates text in the list, starting from index startpos

    Returns: integer: The index in the list where text was found. Zero if not found.

    Category: List Control

    Note, findItem will only check the first column of a ListView.
    If istartpos is negative, the list is scanned from the last item such that -1 means start at the last item, -2 from the second last item etc... A value of 0 means that all occurances are returned in a sequence. Example:

    integer ipos sequence allpos

    -- See if new value already exists. ipos = findItem( TheList, NewValue, 1 ) -- Get all occurances of "cat" allpos = findItem( TheList, "cat", 0) -- Get last occurance of "dog" ipos = findItem( TheList, "dog", -1)

    See Also: addItem, deleteItem, eraseItems, getCount, getIndex, getItem, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getCount
    ( list )

    Get the count of items in list ( List of Combo )

    Returns: Count of items, or zero if control's list is empty.

    Category: List Control

    This returns zero if list is not an appropriate control type.

    Example:

              -- count size of TheList
              integer count
    

    count = getCount( TheList )

    getCount also works with ListView controls.

    See Also: addItem, deleteItem, eraseItems, findItem, getIndex, getItem, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getIndex
    ( list )

    Get the index of the selected item(s), or cursor position in an edit control.

    Returns: INTEGER: Index of selected item, or zero if no item is selected.

    Category: List Control

    For ListView and TreeView, this returns a sequence of all selected items.

    For MleEdit, EditText and RichEdit, this returns the cursor position.

    For Combos this returns

    For List, this returns the index of the currently selected item.

    For Window, VScroll, HScroll, VTrackBar, HTrackBar, ProgressBar, UpDown this returns the current scroll position.

    Example:

              -- get index of selected item in TheList
              integer index
              index = getIndex( TheList )
    

    integer CPos CPos = getIndex( myRichEdit )

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getItem, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getItem
    ( integer list, integer index )

    Return the text of item at index in list.

    Returns: Text of item, or "" if fails.

    Category: List Control

    Note, getItem() will return the text from all columns of a ListView.

    If index is zero, the currently selected item is used.

    Example:

              -- get the text of the third item in TheList
              sequence text
    

    -- get the text of the third item. text = getItem( TheList, 3 ) -- get the text of the current item. text = getItem( TheList, 0 )

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getIndex, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getMultIndices
    ( id )

    Get indices of multiple selections in a multi-selection list

    Returns: Sequence of indices. {} is returned if there are none selected.

    Category: List Control

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getIndex, getItem, getMultItems, insertItem, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    getMultItems
    ( id )

    Get text of multiple selections in a multi-selection list

    Returns: Sequence of strings. {} is return if nothing is selected.

    Category: List Control

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getIndex, getItem, getMultIndices, insertItem, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    insertItem
    ( integer list, sequence text, integer position )

    Insert text into list at position.

    Returns: INTEGER: The position actually used by Windows. Zero is returned if it fails.

    Category: List Control

    The position starts at 1, but if you use zero, it adds it to the end of the list.

    see also: addItem()

    Example:

              -- insert "Bananas" at position 2 in TheList
               insertItem( TheList, "Bananas", 2 )
              -- insert "Mangoes" to the end of TheList
               insertItem( TheList, "Mangoes", 0 )
    

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getIndex, getItem, getMultIndices, getMultItems, setIndex, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setIndex
    ( atom list, object index )

    Set the selected item on the list to index.

    Category: List Control

    This is used for Lists, Combo, and Treeview controls.

    Use 0 to set the index to 'unselected.'
    Use -1 to set the index to the last item.
    Note that if index is greater than the number of items in the list then the last item will be selected.

    Example:

              -- select the first item on the list
               setIndex( TheList, 1 )
              -- select the last item on the list
               setIndex( TheList, -1 )
    

    -- deselect all items in the treeview setIndex( MyTreeView, 0)

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getIndex, getItem, getMultIndices, getMultItems, insertItem, setListHScroll, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [func]
    setListHScroll
    (integer id)

    Recalculates the size of a horizontal scroll bar on a listbox.

    Returns: INTEGER: The length, in characters, of the longest item in the list.

    Category: List Control

    Note that it returns -1 if the id used is not a list box. Example:

          -- Redraw the horizontal scroll bar
          res = setListHScroll(mylist)
    

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getIndex, getItem, getMultIndices, getMultItems, insertItem, setIndex, setSelection, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setSelection
    ( atom list, object index )

    An alias for setIndex

    Category: List Control

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getIndex, getItem, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setTabs, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    setTabs
    ( id, tabs )

    Set/change tab stops in a List or SortedList Control.

    Category: List Control

    tabs should be a sequence of integers. Each one is a tabstop position measured in 1/4 character widths.

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getIndex, getItem, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setSelection, w32AllItems


    Documentation for Win32lib v0.60.6
    Table of Contents

    [const]
    w32AllItems

    This signifies that all items are to be deleted.

    Category: List Control

          atom rc
          rc = deleteItem(myCombo, w32AllItems)
    

    See Also: addItem, deleteItem, eraseItems, findItem, getCount, getIndex, getItem, getMultIndices, getMultItems, insertItem, setIndex, setListHScroll, setSelection, setTabs