.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Thumbnail of images in ListView Control

Posted By:Hiren Soni       Posted Date: August 03, 2010    Points: 10    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

it will create thumbnail and store it to imagelist and then it adds images to listview using imagelist
 

private void button1_Click(object sender, EventArgs e)

{

imageList.Images.Clear();

opend1.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.

*)|*.*";

opend1.Multiselect = true;

if (opend1.ShowDialog() == DialogResult.OK)

{

listView1.View = View.LargeIcon;

imageList.ImageSize = new Size(256,256);

for(int c = 0; c < opend1.FileNames.Length; c++)

{

Image i = Image.FromFile(opend1.FileNames[c].ToString());

Image img = i.GetThumbnailImage(1000,1000, null, new IntPtr());

imageList.Images.Add(img);

}

listView1.LargeImageList = imageList;

for (int j = 0; j < imageList.Images.Count; j++)

{

ListViewItem lstItem = new ListViewItem();

lstItem.ImageIndex = j;

listView1.Items.Add(lstItem);

}

}

}

 




     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend