开发者

How to implement an ListView containing images with style

开发者 https://www.devze.com 2022-12-31 06:47 出处:网络
So I have been working with an app where I need to show the thumbnails as clean and use the space in a good way.

So I have been working with an app where I need to show the thumbnails as clean and use the space in a good way.

Style A is my work until now. What I want to accomplish is something like style B. no titles and use the space in a good way. I need help with this. there was no tutorial on the net. Is ListView able to do such a thing? or shall I make picturesboxes and put them in a scrollview?

the code:

    private void button1_Click(object sender, EventArgs e)
        {

            ImageList myImageList = new ImageList();
            myImageList.ImageSize = new Size(48, 48);

            DirectoryInfo dir = new DirectoryInfo(@"C:\img");
            foreach (FileInfo file in dir.GetFiles())
            {
                try
                {
                    myImageList.Images.Add(Image.FromFile(file.FullName));
                }
                catch
                {
                    Console.WriteLine("This is not an image file");
                }
            } 
myListView.LargeImageList 开发者_JAVA百科= myImageList; 
            myListView.Items.Add("a", 0); 
            myListView.Items.Add("b", 1);
            myListView.Items.Add("c", 2);

How to implement an ListView containing images with style


Are you specifically limited to using Winforms or can you use WPF? It'll make creating that quite easy.

0

精彩评论

暂无评论...
验证码 换一张
取 消