Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

MoverBars

This property determines whether or not a list has a little button at the side of each item that lets you slide the items around and change the list’s order.

Usage

lstList.MoverBars = lHasMoverButtons
lHasMoverButtons = lstList.MoverBars

As the help indicates, MoverBars are relevant only when the RowSourceType for the list is either 0 or 1. That is, you can only move things around when the list “owns” the items. When the list is simply borrowing the items from another source, like a table or array, it can’t change their order. (That’s why Sorted applies only to some RowSourceTypes, too.)

When items are moved around in the list, their index changes. If an item is highlighted and you move it, the value of the list’s ListIndex (index for the currently highlighted item) changes. The List Property is the key to finding out what’s where. It contains all the items in the order you’re seeing them. In addition, InteractiveChange fires when items are moved.

In VFP 3, the interaction of moving items with multi-select is pretty nicely implemented. If you’re careful and touch only the mover buttons, not the items themselves, the selection status of the items doesn’t change. In other words, you can highlight a bunch of items, then move items around and still end up with the same items highlighted.

Unfortunately, they broke it. In VFP 5 and VFP 6, when you move items in a multi-select list, the highlight stays in the same position rather than moving with the items. That is, you have the items with the same set of indexes highlighted, rather than the items with the same ItemIDs. This also means that ListIndex doesn't change when you move a highlighted item in a multi-select list.

It's still broken in VFP 7, but differently. In that version, after you finish moving a highlighted bar, it does get highlighted. Unfortunately, so does the bar that now occupies its former location. ListIndex is also correct in this case—it points to the newly moved bar. Closer—maybe in VFP 8, they'll finally get it right.

Example

frmMyForm.lstSomeList.MoverBars = .T.

See Also

InteractiveChange, List Property, ListBox, ListIndex