ListView

A native list view in report (details) mode.

Constructors

this
this(Widget parent)

Create a report-mode list view as a child of parent.

Members

Functions

addColumn
int addColumn(string title, int width, ColumnAlign align_)

Append a column with the given header title, pixel width and text alignment. Returns the new column's index.

addItem
int addItem(string[] cells)

Append a row. cells[0] is the main item text; cells[1 .. $] fill the subsequent columns. Returns the new row index, or -1 if cells is empty.

autoSizeColumn
void autoSizeColumn(int col, ColumnAutoSize mode)

Size column col to fit its content (ColumnAutoSize.content) or its header text (ColumnAutoSize.header) — the equivalents of WinForms' -1 and -2 column widths.

clear
void clear()

Remove all rows (and release any retained item data; see setItemData).

ensureVisible
void ensureVisible(int index)

Scroll the row at index into view.

getColumnWidth
int getColumnWidth(int col)

Get the pixel width of column col.

getColumnsOrder
int[] getColumnsOrder()

Get the current left-to-right display order of the columns.

getItemCount
int getItemCount()

Return the number of rows.

getItemData
void* getItemData(int index)

Retrieve the user pointer associated with the row at index.

getItemText
string getItemText(int row, int col)

Return the text of the cell at the given row and col.

getPreferredSize
Size getPreferredSize()

A sensible default size for a report-mode list.

getSelectedIndex
int getSelectedIndex()

Return the index of the selected row, or -1 if nothing is selected.

processNotify
bool processNotify(NMHDR* header)

Route list-view selection and activation notifications to their events.

processSubclassed
bool processSubclassed(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT result)

Turn WM_CONTEXTMENU into onContextMenu. The message is raised by a right-click and by the keyboard (Apps key / Shift+F10); the latter arrives with a position of (-1, -1), in which case the menu is anchored at the selected row so a keyboard user gets the menu where focus is.

setColumnTitle
void setColumnTitle(int col, string title)

Change the header text of column col (e.g. when the UI language changes).

setColumnWidth
void setColumnWidth(int col, int width)

Set the pixel width of column col. For autosizing, use autoSizeColumn.

setColumnsOrder
void setColumnsOrder(int[] order)

Set the left-to-right display order of the columns.

setItemData
void setItemData(int index, void* data)

Associate an opaque user pointer with the row at index.

setSelectedIndex
void setSelectedIndex(int index)

Select (and focus) the row at index.

Variables

onContextMenu
Event!(int, MouseEventArgs) onContextMenu;

Fired when a context menu is requested, carrying the relevant row index (-1 if none) and the screen position to show the menu at. Raised both by a mouse right-click (row under the cursor) and by the keyboard — the Apps key or Shift+F10 — in which case the row is the selected one and the position is anchored to it. The screen coordinates can be passed to showPopupMenu.

onItemActivated
Event!(int) onItemActivated;

Fired when a row is activated (double-click or Enter); argument is the row index.

onSelectionChanged
Event!(int) onSelectionChanged;

Fired when the selected row changes; argument is the new selected index.

Inherited Members

From Control

controlId
int controlId()

The control's command identifier (the hMenu child id at creation).

setText
void setText(string text)

Set the control's text.

getText
string getText()

Get the control's text.

setFont
void setFont(HFONT font)

Assign a font to the control and request a repaint.

getPreferredSize
Size getPreferredSize()

A reasonable default preferred size; override per control type.

processCommand
bool processCommand(ushort notificationCode)

Handle a WM_COMMAND notification routed from the parent.

processNotify
bool processNotify(NMHDR* header)

Handle a WM_NOTIFY notification routed from the parent. Return true if it was handled. The default does nothing.

subclass
void subclass()

Install a subclass window procedure so the control can intercept its own messages (for example, swallowing the Enter key in a text field). Idempotent. Subclasses override processSubclassed to do the work.

processSubclassed
bool processSubclassed(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT result)

Intercept a message while subclassed. Set result and return true to consume the message; return false to let default processing continue.

Meta