Winforms 将文件夹中的图像显示到Listview窗口表单C++/CLI 我在Windows窗体C++上创建了一个应用程序,我想在我的文件夹中显示一些图像到ListVIEW(ListVIEW1)。它已成功编译,但我无法使图像显示

Winforms 将文件夹中的图像显示到Listview窗口表单C++/CLI 我在Windows窗体C++上创建了一个应用程序,我想在我的文件夹中显示一些图像到ListVIEW(ListVIEW1)。它已成功编译,但我无法使图像显示,winforms,visual-c++,c++-cli,Winforms,Visual C++,C++ Cli,这是我的密码: ImageList ^ imgs = gcnew ImageList(); imgs->ImageSize = System::Drawing::Size(100, 100); array<String^> ^paths = {}; paths = System::IO::Directory::GetFiles("Picture"); try { for each (String ^ path in paths) { imgs-&

这是我的密码:

ImageList ^ imgs = gcnew ImageList();
imgs->ImageSize = System::Drawing::Size(100, 100);
array<String^> ^paths = {};
paths = System::IO::Directory::GetFiles("Picture");
try
{
    for each (String ^ path in paths)
    {
        imgs->Images->Add(Image::FromFile(path));
    }
}
catch (Exception ^ e) {}
this->listView1->SmallImageList = imgs;
ImageList^imgs=gcnew ImageList();
imgs->ImageSize=System::Drawing::Size(100100);
数组^paths={};
路径=系统::IO::目录::获取文件(“图片”);
尝试
{
对于每个(路径中的字符串^path)
{
imgs->Images->Add(Image::FromFile(path));
}
}
捕获(异常^e){}
此->列表视图1->SmallImageList=imgs;

非常感谢。

代码不足以显示图像。您还必须将项目添加到ListView并设置其ImageIndex属性。好的,我知道问题出在哪里。我的代码不够。它现在运行得和我预期的一样。非常感谢你!