list-view controls中一个item代表一行,设置这行的信息通过subitem。

Each item can have one or more subitems. A subitem is a string that, in report view, is displayed in a column separate from the item's icon and label. All items in a list-view control have the same number of subitems. The number of subitems is determined by the number of columns in the list-view control. When you add a column to a list-view control, you specify its associated subitem index. The iItem member is the zero-based index of the item. The iSubItem member is the one-based index of a subitem or zero if the structure contains information about an item. To change the attributes of a list-view item, use the LVM_SETITEM message, specifying the address of an LVITEM structure. The mask member of this structure specifies the item attributes you want to change. For example, to change only the text of an item or subitem, use the LVM_SETITEMTEXT message.

Report (details) view: Each item appears on its own line, with information arranged in columns. The leftmost column is always left justified and contains the small icon and label. Subsequent columns contain subitems as specified by the application.


HWND hWnd = GetDlgItem(hDlg, IDC_LIST1);
LVCOLUMN lvc = {0};
lvc.fmt = LVCFMT_CENTER; = 20;
lvc.iSubItem = 0;
lvc.pszText = TEXT("");
ListView_InsertColumn(hWnd, 0, &lvc); = 100;
lvc.iSubItem = 1;
lvc.pszText = TEXT("编号");
ListView_InsertColumn(hWnd, 1, &lvc);
LVITEM lvi = {0};
lvi.mask = LVIF_TEXT;
lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.pszText = TEXT("");
ListView_InsertItem(hWnd, &lvi);
ListView_SetItemText(hWnd, 0, 1, TEXT("1"));
lvi.iItem = 1;
ListView_InsertItem(hWnd, &lvi);
ListView_SetItemText(hWnd, 1, 1, TEXT("2"));