By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

How do i open files as thumbnails in listview?

P: 4
hi I am a beginner in C# programming
can someone pleas help me with this

I am creating an application in c# with vs and I want to open image selected in openfiledialog as thumbnails in a list view from the open file dialog but i don`t know where to begin can someone pleas help me.
Mar 9 '09 #1
Share this Question
Share on Google+
6 Replies

Expert 100+
P: 221
Hi and welcome to the forums.

How about the help files? MSDN?

Resources for learning C#
Mar 9 '09 #2

P: 4
I went trough them but i can find any thing that can help me
Mar 9 '09 #3

Expert 100+
P: 221
The links I posted contain plenty of resources for learning and all the information you would need to implement what you require. Is there a specific problem within the implementation that you are having?
Mar 9 '09 #4

Expert 5K+
P: 7,872
Sounds like you need to learn the following:
Using the OpenFileDialog
Opening a file (either as a file, or using the Bitmap/Image .FromFile() function)
Create a thumbnail from an Image object
Use images in listviews

Start learning each of those items and you'll be able to put them together yourself.
Mar 9 '09 #5

P: 4
HI thanks nukefusion this is Wat i got But i Don`t know how to get the
listview to show the files/open them.
Expand|Select|Wrap|Line Numbers
  1. OpenFileDialog MyDialog = new OpenFileDialog();
  2.             MyDialog.Multiselect = true;
  3.             MyDialog.Filter = "JPEG files (*.jpg)|*.jpg|All files (*.*)|*.*";
  4.             MyDialog.RestoreDirectory = true;
  5.             MyDialog.Title = "Add Files";
  9.             Stream myStream = null;
  11.             if (MyDialog.ShowDialog() == DialogResult.OK)
  12.             {
  13.                 try
  14.                 {
  15.                     if ((myStream = MyDialog.OpenFile()) != null)
  16.                     {
  17.                         using (myStream)
  18.                         {
  19.                             // listView1.??????????????????????? 
  20.                         }
  21.                     }
  22.                 }
  23.                 catch (Exception ex)
  24.                 {
  25.                     MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
  26.                 }
  27.             }
I also tried getting the directory and then use it in the picbox image location
it worked but its mad because you have to get all the directories of the files you selected and then use it in the picbox.And if you select to many or to few you get an error. saying Value out side array.
Mar 10 '09 #6

Expert 5K+
P: 7,872
I would use the ImageFromFile() function on the Bitmap class to open the jpeg files.
Then make a copy of the object
Then close the original object (releases the file)
Then assign it to the listview
Mar 10 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.