
顯示的灰色部分文字就是SubItems裏面的。

作者共發了4篇帖子。
![]() |
![]() 顯示的灰色部分文字就是SubItems裏面的。 ![]() |
![]() |
![]() ![]() |
![]() |
【方法】
插入Item時,設置LV_ITEM結構體的mask,cColumns和puColumns成員變量即可。 請看示例: // Add items UINT columns[] = {1, 2}; // 顯示第一、第二欄的內容 LV_ITEM lvi; lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_COLUMNS; // 加上LVIF_COLUMNS掩碼 lvi.iSubItem = 0; // 必須在創建主項目時設置 lvi.cColumns = sizeof(columns) / sizeof(UINT); // 指定欄目數,這裏是2 lvi.puColumns = columns; // 指向數組columns的指針,這個數組無需動態創建 for (i = 0; i < len; i++) { lvi.pszText = itemNames[i]; lvi.iImage = i; lvi.iItem = i; ListView_InsertItem(ctrls.hListBox, &lvi); } |
![]() |
【MSDN參考資料】
連結:https://msdn.microsoft.com/en-us/library/windows/desktop/bb774760%28v=vs.85%29.aspx cColumns Type: UINT Version 6.0 Number of data columns (subitems) to display for this item in tile view. The maximum value is 20. If this value is I_COLUMNSCALLBACK, the size of the column array and the array itself (puColumns) are obtained by sending a LVN_GETDISPINFO notification. 在平鋪視圖中以灰色文字顯示的欄目數量,最大值為20。如果這個成員變量的值被設為I_COLUMNSCALLBACK的話,那麼程序應該在LVN_GETDISPINFO消息中返回欄目數量以及具體的欄目編號數組。 puColumns Type: PUINT Version 6.0 A pointer to an array of column indices, specifying which columns are displayed for this item, and the order of those columns. 指向欄目編號的數組。欄目嚴格按數組中的順序顯示。 In tile view, the item name is displayed to the right of the icon. You can specify additional subitems (corresponding to columns in the details view), to be displayed on lines below the item name. The puColumns array contains the indices of subitems to be displayed. Indices should be greater than 0, because subitem 0, the item name, is already displayed. Column information can also be set in the LVTILEINFO structure when modifying the list item. 在平鋪視圖中,項目名稱顯示在圖標的右邊。你可以指定以灰色文字顯示的詳細信息。 |