How to implement an ListView containing images with style
Posted
by Alexandergre
on Stack Overflow
See other posts from Stack Overflow
or by Alexandergre
Published on 2010-05-21T00:51:31Z
Indexed on
2010/05/21
1:00 UTC
Read the original article
Hit count: 347
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 = myImageList;
myListView.Items.Add("a", 0);
myListView.Items.Add("b", 1);
myListView.Items.Add("c", 2);
© Stack Overflow or respective owner