List box

from Wikipedia, the free encyclopedia
pick list

A list box ( English listbox , also selection list ) is a control element ( control, component ) of a graphical user interface (GUI). It is used to display entries that can be selected by the user in list form. The entries are usually data of a textual nature, but pictograms or combinations of text and images are also possible.

Types of list boxes

A distinction is made between different types of list boxes:

  • The normal list field has several lines. For ergonomic reasons, it is recommended to have at least four lines. Since there are usually more entries in the list than the number of lines in the field, a vertical scroll bar is used to scroll through the list.
  • In addition to the permanently visible multi-line list box, there is also the space-saving single-line drop-down list box ( drop-down list box, drop-down list ). The complete list only appears when you press the associated button in the form of a menu (pop-up menu, context menu) that allows you to select an entry.
  • The combination of list box and a text box ( Text Field ) for direct input and output is called a combo box ( combo box ).
  • Extended list fields with symbols, text and / or several columns, as they are often found in file managers , are also called list views .

Which entries - as suggestions for selection by the user - are displayed at which point in time in the list field depends on the programming of the respective application. It also depends on the details of the implementation of the list field in a computer program whether only one or more entries can be selected. In the case of single-line list fields, only one entry can usually be selected.

Examples

Java

There are different list boxes in the Java programming language

AWT

  • The multi-line list box is called java.awt.List
  • The one-line drop-down list box is called java.awt.Choice

swing

  • The multiline list box is called javax.swing.JList
  • The one-line drop-down list box is called javax.swing.JComboBox . Since this is a combo box, you must define whether it should only be used for selection or whether it should also accept entries via the integrated text field (  setEditable(true) ).

HTML

In the markup language HTML there is only the element <select> for selection lists

  • The one-line list field is created with <select size=1>
  • The multi-line list field is created with <select size=2>(or more)

Excel Visual Basic

The example transfers the data from an Excel spreadsheet to the list box. It is limited to three columns, but can be expanded.

  • Load an Excel file (e.g. addresses) or create such a file. Save the file under the name "Listbox".
  • Create a user form with the name "Userform1" and a list field with the name "Listbox1".
  • Copy the following user form code:
Private Sub UserForm_Initialize()
   'Listbox füllen
    ListBox1.ColumnCount = 3
    ListBox1.BoundColumn = 0
    ListBox1.RowSource = "mappe.xls!A1:C3"
End Sub