Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This macro inserts a new item in a list-view control. You can use this macro or send the LVM_INSERTITEM message explicitly.

Syntax

int ListView_InsertItem( 
  HWND 
hwnd, 
  const LVITEM FAR* 
pitem 
);

Parameters

hwnd

Handle to the list-view control.

pitem

Pointer to an LVITEMstructure that specifies the attributes of the list-view item. The iItemmember of the structure specifies the index of the new item.

You cannot use ListView_InsertItemor LVM_INSERTITEM to insert subitems; the iSubItemmember of the LVITEMstructure must be zero.

Return Value

The index of the new item indicates success. -1 indicates failure.

Remarks

If a list-view control has either the LVS_SORTASCENDING or LVS_SORTDESCENDING window style, an LVM_INNSETITEM message will fail if you try to insert an item that has LPSTR_TEXTCALLBACK as the pszTextmember of its LVITEMstructure.

Related message:  LVM_INSERTITEM

Requirements

Header commctrl.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also