OnMoveItem Event

Occurs when you select and move an item up or down in a list box using the mouse, keyboard, or programmatically with the MoveItem method.

PROCEDURE OnMoveItem
LPARAMETERS nSource, nShift, nCurrentIndex, nMoveBy

Parameters

  • nSource
    Contains a number that specifies how the event is triggered.

    nSource Description
    0 Keyboard
    1 Left mouse button
    2 Right mouse button
    4 Middle mouse button
    8 Programmatically triggered by the MoveItem method
  • nShift
    Contains a number that specifies which modifier keys, SHIFT, CTRL, and ALT, are also pressed when the mouse button is pressed. The following table lists the values returned by nShift for individual modifier keys.

    nShift Description
    1 SHIFT
    2 CTRL
    4 ALT

    If more than one modifier key is held down when the mouse button is pressed, the nShift argument contains the sum of the values for the modifier keys. For example, if the user holds CTRL while pressing the mouse button, the nShift argument contains a value of 2. However, if the user holds down CTRL+ALT while pressing the mouse button, the nShift argument contains a value of 6.

  • nCurrentIndex
    Contains the current index of the item being moved.

  • nMoveBy
    Indicates how many positions the item is being moved. A positive value indicates downward movement. A negative number indicates upward movement.

    The nMoveBy parameter always has a value of 1 or -1 if the user is moving a list item using the keyboard. It usually has a value of 1 or -1 if the user is moving a list item using the mouse. However, nMoveBy indicates the position to which the item is moved if the user drags the mouse outside the bounds of the list box and then back to a remote position.

Remarks

OnMoveItem occurs after selecting and moving an item by pressing CTRL+UP ARROW, CTRL+DOWN ARROW or by using the mouse, or when calling the MoveItem method programmatically. OnMoveItem occurs after every subsequent move but before the list box displays the item movement. However, OnMoveItem occurs only once when calling the MoveItem method programmatically.

Note   You can move ListBox control items only if the grid's RecordSourceType property is set to 0 (None) or 1 (Value).

To prevent movement from occurring, return False (.F.) from the code in the OnMoveItem event.

See Also

Events | MoveItem Method | RecordSourceType Property | MoverBars Property

Applies To: ListBox Control