ListView Ocx

Purpose

Creates an Ocx ListView control in the current active form, window, or dialog.

Syntax

Ocx ListView name = text$ [, id%], x, y, w, h[, style%]

text$:control text
id%:control identifier
x, y, b, h:iexp
style%:the control styles

Description

The ListView control displays items using one of four different views. You can arrange items into columns with or without column headings as well as display accompanying icons and text.

With a ListView control, you can organize list entries, called ListItem objects, into one of four different views: Large (standard) Icons, Small Icons, List, and Report

The View property determines which view the control uses to display the items in the list. You can also control whether the items in the list are sorted and how selected items appear.

The ListView control contains ListItem and ColumnHeader objects. A ListItem object defines the various characteristics of items in the ListView control, such as:

- A brief description of the item.

- Icons that may appear with the item, supplied by an ImageList control.

- Additional pieces of text, called subitems, associated with a ListItem object that you can display in Report view.

You can choose to display column headings in the ListView control using the Add method to add a ColumnHeader object to the ColumnHeaders collection.

The ListView Ocx control has the following properties, methods, and events.

Properties

Appearance | Arrange | BackColor | BorderStyle | CheckBoxes | CheckedCount | CheckedItems | ColumnHeaders | Count | DefaultWidth | Enabled | ExStyle | Font | FontBold | FontItalic | FontStrikethru | FontUnderline | FontName | FontSize | ForeColor | FullRowSelect | Grid | GridLines | Height | HelpContextID | HideSelection | hWnd | Icons | Index | LabelEdit | Left | ListItems | MouseCursor | MouseIcon | MousePointer | MultiSelect | Name | Parent | SelectedItem | SmallIcons | TabStop | Tag | TextBackColor | ToolTiptext | Top | TopIndex | View | Visible | WhatsThisHelpID | Width

Methods

Add | AddItem | Clear | GetFirstVisible | HitTest | Item, | LineItem | ListItem | Move | Refresh | Remove | SelectedCount | SelectedItems | SetFocus | SetFont | SetGrid | SnapToGrid | Sort | StartLabelEdit | TextHeight | TextWidth | VisibleCount | ZOrder

The VisibleCount method returns an integer from 0 to the number of items visible in the control. An item is considered visible even if only a portion of the text is visible.

Events

AfterLabelEdit | BeforeLabelEdit | Click | ColumnClick | DblClick | GotFocus | ItemClick | KeyDown, KeyUp | KeyPress | LostFocus | MouseDown | MouseUp | MouseMove

Example

OpenW 1, 20, 20, 500, 500

' View property

Global Enum lvwIcon = 0, lvwSmallIcon, lvwList, lvwReport

' Arrange property (valid for lvwIcon, lvwSmallIcon)

Global Enum lvwNone = 0, lvwAutoLeft, lvwAutoTop

' LabelEdit property

Global Enum lvwAutomatic = 0, lvwManual ' ListView

Dim lis As ListItems, li As ListItem

Dim chs As ColumnHeaders, ch As ColumnHeader

Ocx ImageList iml

iml.ListImages.Add , "comp", CreatePicture(LoadIcon(Null, IDI_APPLICATION))

Ocx ListView lv = "", 10, 10, 230, 200

lv.View = lvwReport

lv.Icons = iml

lv.SmallIcons = iml

Set ch = lv.ColumnHeaders.Add( , "1" , "Column #1")

ch.Width = 2000

lv.ColumnHeaders.Add , "2", "Column #2"

lv.ColumnHeaders.Add , "3" , "Column #3"

lv.Add , , "ListItem #1", "comp"

lv.ListItems.Add , , "ListItem #2", "comp"

lv.AddItem , , "ListItem #3", "comp"

lv.AddItem , , "ListItem #4", "comp"

lv.AddItem , , "ListItem #5", "comp"

lv.AddItem , , "ListItem #6", "comp"

lv.AddItem , , "ListItem #7", "comp"

lv.GridLines = True

'lv.Grid 1 // Does not work

Do

Sleep

Until Me Is Nothing

Remarks

Further control on the individual list items is performed with ListItem objects of the ListItems collection.

The gfawinx library defines the following constants:

For use with the View property: lvwIcon, lvwSmallIcon, lvwList, and lvwReport.
For use with the Arrange property: lvwNone, lvwAutoTop, and lvwAutoLeft.
For use with the LabelEdit property: lvwAutomatic, lvwManual.

See Also

ListItems, ListItem

Ocx, OcxOcx

Animation, CheckBox, ComboBox, Command, CommDlg, Form, Frame, Image, ImageList, Label, ListBox, MonthView, Option, ProgressBar, RichEdit, Scroll, Slider, StatusBar, TabStrip, TextBox, Timer, TrayIcon, TreeView, UpDown

{Created by Sjouke Hamstra; Last updated: 13/08/2019 by James Gaite}