且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C# .net Windows 窗体列表视图,在详细视图中显示图像

更新时间:2023-01-31 09:41:25

希望下面的代码可以帮到你.使用 C#

Hope that the following code can help you out. using C#

ImageList il = new ImageList();
il.Images.Add("test1", Image.FromFile(@"c:DocumentsSharpDevelop Projectslearning2learning2Koala.jpg"));

listView1.View = View.LargeIcon;
listView1.LargeImageList = il;
listView1.Items.Add("test");

for(int i = 0; i < il.Images.Count; i++)
{
    ListViewItem lvi = new ListViewItem();
    lvi.ImageIndex = i;
    lvi.Text="koala 1";
    listView1.Items.Add(lvi);
}

运行这种代码可以获得列表视图中的图像和文本.有关更多详细信息,请参阅此 帖子

Running this kind of code can get you the image and the text in a listview. For further more details, refer to this post