NewDirListBox

Description

Adds a directory listbox control to a form.

Syntax

[Set oCtl =] oFrm.NewDirListBox

( Name, Left, Top, Width, Height, [Container] )

Parameters

Part

Description

Set oCtl =

(optional) Store a reference to the new control in the variable oCtl. This variable can be used to access the control's properties and methods.

oFrm

A reference to a form object (see the NewForm method)

Name

The name of the control. It must be unique within the form and may not be empty or start with an asterisk (*)

Left

See the list of properties below

Top

See the list of properties below

Width

See the list of properties below

Height

See the list of properties below

Container

(optional) The name of an existing frame control that will act as container for the listbox. If unspecified or an empty string, the Form itself will be the container. Please note that the Left and Top properties are relative to the container's left and top edges

Properties, Methods and Events

Property

Description

BackColor

Background color (use the RGB function to assign a color value)

Enabled

(boolean) Determines if the control can respond to user-generated events

Fontname

The font used to display text. The default is determined by the system. Check the glossary for an explanation about setting font properties.

Fontsize

The size of the font in points. The maximum is 2160 points.

Fontbold

(boolean) Enable or disable the bold style of a font

Fontitalic

(boolean) Enable or disable the italic style of a font

Fontstrikethru

(boolean) Enable or disable the strikethru style of a font

Fontunderline

(boolean) Enable or disable the underline style of a font

ForeColor

Foreground color (use the RGB function to assign a color value)

Height

The height of the control in twips

Left

The distance from the left edge of the specified container in twips

List (index)

(read-only) The directory at the specified index. The first item has index -n and the last item has index ListCount – 1. The directory that is currently expanded is represented using the index –1. The directories above the currently expanded directory are represented by negative indexes with higher absolute values. For example, –2 is the parent directory of the directory that is currently expanded and –3 is the directory above that. Directories below the expanded directory range from 0 to ListCount – 1.

ListCount

(read-only) The number of subdirectories in the current directory

ListIndex

(integer) Returns or sets the index of the currently selected item

-1

(default) Indicates the index of the current path

n

A number indicating the index of the currently selected item.

Parent

(read-only) Returns the parent form, object or collection. You can use the parent property to access the properties and methods of an object's parent

Path

(string) Returns or sets the current path. The default is the current path when the control is created at run time. Setting the Path property has effects on a control similar to the MS-DOS ChDir command. Relative paths are allowed with or without a drive specification. Specifying only a drive with a colon (:) selects the current directory on that drive. The Path property can also be set to a qualified network path without a drive connection using the following syntax: \\servername\sharename\path. This syntax changes the Drive property to a zero-length string ("").

TabStop

(boolean) Determines whether the TAB key can be used to move the focus

Tag

(reserved) Used internally to store the user-defined controlname

ToolTipText

Explanatory text that appears in a small rectangle below the object when you pause the mouse pointer (hover) over it for about one second

Top

The distance from the top edge of the specified container in twips

TopIndex

(integer) The index of the item displayed in the topmost position

Visible

(boolean) Determines whether the control is visible or hidden

Width

The width of the control in twips

Method

Description

Move

Parameters: left [, top [, width [, height ]]]

Only the left argument is required. However, to specify any other arguments, you must specify all arguments that appear in the syntax before the argument you want to specify. For example, you can't specify width without specifying left and top. Any trailing arguments that are unspecified remain unchanged

Refresh

Forces a complete repaint of a control

SetFocus

Moves the focus to the specified control

Event

Description

Event raised

Change

Occurs when the user changes the selected directory, by double-clicking a new directory or when you change the Path property through code

Controlname

Click

Occurs when the user changes the selected directory by clicking a new directory

KeyUp

Occurs when a key is released when the DirListBox has the focus. The following keys are handled: Arrow keys, Home, End, PageUp, PageDown and Enter key

To be able to handle events you need to operate a form in callback mode.
This subject is described in the following topics:
Callback forms, ClickHandler

Example

See the NewFileListBox page for a complete, integrated example of using the three related controls; the DriveListBox , DirListBox and FileListBox controls.