如何:顯示 Windows Form ListView 控制項的圖示
Windows Forms ListView 控制項可以顯示來自三個影像清單的圖示。 List、Details 和 SmallIcon 檢視會顯示 屬性中所 SmallImageList 指定影像清單中的影像。 LargeIcon 檢視會顯示 屬性中所 LargeImageList 指定影像清單中的影像。 清單檢視也可以顯示一組額外的圖示,在 屬性中 StateImageList 設定,位於大型或小型圖示旁邊。 如需影像清單的詳細資訊,請參閱 ImageList 元件 和 如何:使用 Windows Forms ImageList 元件 新增或移除影像。
在清單檢視中顯示影像
將適當的屬性 SmallImageList 、、 LargeImageList 或 StateImageList 設定為您想要使用的現有 ImageList 元件。
您可以使用 屬性視窗 或程式碼,在設計工具中設定這些屬性。
listView1.SmallImageList = imageList1;
ListView1.SmallImageList = ImageList1
ImageIndex設定具有相關聯圖示之每個清單專案的 或 StateImageIndex 屬性。
這些屬性可以在程式碼中設定,或在 ListViewItem 集合編輯器 中 設定。 若要開啟 ListViewItem 集合編輯器 ,請按一下 [屬性 ] 視窗上 屬性旁邊的 Items 省略號按鈕 ( )。
// Sets the first list item to display the 4th image. listView1.Items[0].ImageIndex = 3;
' Sets the first list item to display the 4th image. ListView1.Items(0).ImageIndex = 3
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應