SetGrid, SnapToGrid Method (ListView)

Purpose

Moves an item to a specified position in a list view control (must be in icon or small icon view).

Syntax

ListView.SetGrid( index, x, y )

ListView.SnapToGrid

index, x, y:iexp

Description

The index parameter specifies the index of the list view item, which should be an Icon or SmallIcon. The x and y parameters specify the new position of the item's upper-left corner, in view coordinates.

If the Arrange property = 0 (no auto arrange) the items in the list view control are arranged when invoking SnapToGrid.

The SnapToGrid method snaps all icons to the nearest grid position.

Example

Local Int32 n

Ocx ImageList iml : .ImageHeight = 32 : .ImageWidth = 32

For n = 32512 To 32518 : iml.Add , "Img " & n, CreatePicture(LoadIcon(Null, n)) : Next n

Ocx ListView lv = "", 10, 10, 400, 300 : .Icons = iml : .SmallIcons = iml : .Arrange = 1

For n = 1 To 7 : lv.Add , , "Icon" & n, n, n : Next n

~lv.SetGrid(2, 90, 100)

lv.SnapToGrid

Do : Sleep : Until Me Is Nothing

Remarks

Rather than just influencing the position of one icon, SetGrid seems to affect the positioning of all.

See Also

ListView, Arrange

{Created by Sjouke Hamstra; Last updated: 23/10/2014 by James Gaite}