How do i open files as thumbnails in listview?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cho Cho
    New Member
    • Oct 2008
    • 4

    How do i open files as thumbnails in listview?

    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.
  • nukefusion
    Recognized Expert New Member
    • Mar 2008
    • 221

    #2
    Hi and welcome to the forums.

    How about the help files? MSDN?

    Resources for learning C#
    OpenFileDialog
    ListView

    Comment

    • Cho Cho
      New Member
      • Oct 2008
      • 4

      #3
      I went trough them but i can find any thing that can help me

      Comment

      • nukefusion
        Recognized Expert New Member
        • Mar 2008
        • 221

        #4
        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?

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          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.

          Comment

          • Cho Cho
            New Member
            • Oct 2008
            • 4

            #6
            HI thanks nukefusion this is Wat i got But i Don`t know how to get the
            listview to show the files/open them.
            [code=c#]
            OpenFileDialog MyDialog = new OpenFileDialog( );
            MyDialog.Multis elect = true;
            MyDialog.Filter = "JPEG files (*.jpg)|*.jpg|A ll files (*.*)|*.*";
            MyDialog.Restor eDirectory = true;
            MyDialog.Title = "Add Files";



            Stream myStream = null;

            if (MyDialog.ShowD ialog() == DialogResult.OK )
            {
            try
            {
            if ((myStream = MyDialog.OpenFi le()) != null)
            {
            using (myStream)
            {
            // listView1.????? ??????????????? ???
            }
            }
            }
            catch (Exception ex)
            {
            MessageBox.Show ("Error: Could not read file from disk. Original error: " + ex.Message);
            }
            }
            [/code]
            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.

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              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

              Comment

              Working...