C# listview中显示imagelist中的图片

在winform中,实现图片列表的功能:
private void LoadImageList()
        {
            var path = Environment.CurrentDirectory+"/Images/";
            var list = new List();
            list.Add("01-01-0001.jpg");
            list.Add("01-02-0002.jpg");
            list.Add("01-03-0003.jpg");
            list.Add("01-04-0004.jpg");
            list.Add("01-05-0005.jpg");
            list.Add("01-06-0006.jpg");
            list.Add("01-07-0007.jpg");

            ImageList imglist = new ImageList();
            imglist.ImageSize=new Size(48,48);
            imglist.ColorDepth = ColorDepth.Depth32Bit;
            foreach (var fileName in list)
            {
                imglist.Images.Add(Image.FromFile(path + fileName));
            }
            picListView.LargeImageList = imglist;

            for (int i = 0; i < imglist.Images.Count; i++)
            {
                var lvi= new ListViewItem();
                lvi.ImageIndex = i;
                lvi.Text = "P" + i;
                lvi.ToolTipText = "P" + i;
                picListView.Items.Add(lvi);
            }
        }


你可能感兴趣的:(C#专区)