ListBox Control

Creates a list box.

ListBox

Remarks

A list box displays a list of items from which you can select one or more items. A list box is similar to a combo box; however, a combo box initially displays a single item.

The backslash ("\") is treated as a special character when used in the expression for an item. The following rules apply for this character:

  • You can disable an item in a list box or combo box by adding a single backslash to the beginning of the expression.

  • Any multiple of two backslashes used in the expression is displayed as a single backslash. For example, one or two backslashes used together will display as one, and three or four backslashes together will display as two. The following example code contains a list box item containing a Universal Naming Convention (UNC) path. The code would display in the list box as \\MyServer\MyMachine\MyFolder.

    MyForm.List1.AddItem("\\\\MyServer\\MyMachine\\MyFolder")
    
  • If the expression begins with multiple backslashes, the item is not disabled. If you want to disable an item that begins with multiple backslashes, add a backslash and a close bracket (]) to the beginning of the item. For example, the following would disable the UNC path item in the list box:

    MyForm.List1.AddItem("\]\\\MyServer\\MyMachine\\MyFolder")
    
  • To include a separator line, use a backslash followed by a hyphen as the item to add to the list box. For example, the following code adds a separator line to a list box:

    MyForm.List1.AddItem("\-")
    

You can also use an ActiveX control that adds extra characteristics, such as a CheckBox, to the ListView or TreeView controls.

For additional information about creating ListBox controls, see Form Designer and Using Controls.

See Also

ListBox Control Properties, Methods and Events | CREATE CLASS | CREATE FORM | DEFINE CLASS