C# 如何在listview的imagelist中添加系统图标

C# 如何在listview的imagelist中添加系统图标,c#,winforms,listview,imagelist,C#,Winforms,Listview,Imagelist,我通过在listview中使用此代码在图像列表中添加了图标。现在,我希望在显示某个目录的列表视图时显示它们 我的问题是: 我需要在imagelist1控件中进行哪些更改?如何在代码中调用imagelist1 imageList1.Images.Add( BlackFox.Win32.Icons.IconFromExtensionShell( ".*", BlackFox.Win32.Icons.SystemIconSize.Small)); //lv.

我通过在listview中使用此代码在
图像列表中添加了图标。现在,我希望在显示某个目录的列表视图时显示它们

我的问题是:

我需要在
imagelist1
控件中进行哪些更改?如何在代码中调用
imagelist1

imageList1.Images.Add(
    BlackFox.Win32.Icons.IconFromExtensionShell(
        ".*", 
        BlackFox.Win32.Icons.SystemIconSize.Small));

//lv.ImageIndex = 1;

如果我理解正确,您希望在ImageList中显示图标以及ListView中的相应文件。为此,只需将ListView对象的
SmallImageList
LargeImageList
属性指向ImageList(取决于ListView使用的图标显示模式)

不要忘记将ImageList中的图标指定给ListView中的项目:

MyListItem.ImageIndex = 0;

或者在添加列表项时立即添加它们:

ListViewItem MyListItem= new ListViewItem("ItemName", "MyImageName");
ListViewItem MyListItem2= new ListViewItem("ItemName2", int ImageIndex);

这个“BlackFox”家伙是谁?它是一个检索系统图标的类。当我将它用作picturebox.image.add(BlackFox.Win32.Icons.IConFromeExtensionShell(“.zip”,BlackFox.Win32.Icons.SystemIconSize.Small));它显示了zip图标我想知道我是否可以用同样的方式将其添加到imagelist中。当显示文件列表时,我会得到带有它们的图标
MyListItem.ImageKey = "MyImageName";
ListViewItem MyListItem= new ListViewItem("ItemName", "MyImageName");
ListViewItem MyListItem2= new ListViewItem("ItemName2", int ImageIndex);