Click here to Skip to main content
15,901,035 members
Home / Discussions / C#
   

C#

 
AnswerRe: Use Mdi from User Control? Pin
Saksida Bojan25-Feb-10 20:16
Saksida Bojan25-Feb-10 20:16 
QuestionThree ComboBoxes, a DataTable, and a BindingSource ? Pin
Matthew Klein25-Feb-10 14:25
Matthew Klein25-Feb-10 14:25 
AnswerRe: Three ComboBoxes, a DataTable, and a BindingSource ? Pin
Arindam Tewary25-Feb-10 19:22
professionalArindam Tewary25-Feb-10 19:22 
QuestionEnter/Leave debug methods? Pin
Jim Turner25-Feb-10 11:46
Jim Turner25-Feb-10 11:46 
AnswerRe: Enter/Leave debug methods? Pin
Abhinav S25-Feb-10 12:17
Abhinav S25-Feb-10 12:17 
AnswerRe: Enter/Leave debug methods? Pin
Eddy Vluggen25-Feb-10 13:08
professionalEddy Vluggen25-Feb-10 13:08 
AnswerRe: Enter/Leave debug methods? Pin
David Skelly25-Feb-10 22:19
David Skelly25-Feb-10 22:19 
QuestionListview Control problem - thumbnail display Pin
Eagle3225-Feb-10 8:03
Eagle3225-Feb-10 8:03 
Hi,

I previously created clickable thumbnails by assigning them to a picturebox instance and
then adding them to the flowlayoutpanel.

So i now i decided to experiment with listview control and ImageList control. I would like to display the thumbnail and the image title. Then once you click on the thumbnail the image appears at its original resolution.

But i'm having some issues and I would appreciate if you could help me please regarding this?

Firstly, I am trying to use an exisiting class that I created which would take in the filepath of the selected image which would then allow me to view the image at its original resolution.

Intially the problem i had regarding the listview was when i click on an image, the selected image didnt come up, another image came up.

For example i loaded 2 images. One called GoldFish.jpg and the other Rabbit.jpg. But when i click on Goldfish, rabbit appears instead.

When i click on Rabbit, Rabbit appears as expected. I think it is something to do with the index possibly?

I have now modified the code so that the in the ImageList i add the key and the actual image. So i decided to store the filepath and the thumbnail.

Regarding the ListView i decided to store the filename along with the filePath e.g "rabbit.jpg", "c:\\sample\\rabbit.jpg"

I then used the mouse click event to access the filePath and pass it into another form.

The following snippet is also causing an issue too:

/if i take this code out, the thumbnails are not displayed but if i click on
//the area where the image is supposed to be, I am able to view the desired image at full res.
for (int j = 0; j < pathes.Length; j++)
{
   this.listView1.Items[j].ImageIndex = j;
}


But if i use the above code then the thumbnails appear but when i click on the image i get the following error message on the click event of the list view.
"Path is not of legal form".


I just want to display the thumbnail images with the filename and when you click on the image you can view the image at
its original resolution.


Here is my full code.
 private void Form1_Load(object sender, EventArgs e)
 {
     imageList1.ImageSize = new Size(108, 108);
     imageList1.ColorDepth = ColorDepth.Depth24Bit;

     string[] pathes = new string [] { @"c:\\sample\\Goldfish.jpg", @"c:\\sample\\Rabbit.jpg" };

     foreach (string path in pathes)
     {

         string[] currentPath = path.Split(new char[] { '\\' });
         string fileName = currentPath[currentPath.Length - 1];
         //create thumbnail
         Image thumbnail = ThumbnailCreator(path);
         //add the path and thumbnail
         imageList1.Images.Add(path,thumbnail);
         listView1.Items.Add(fileName,path);

         //listView1.Tag = path;
        //i tried to set the click event for the listview here but the imageviewer instance would appear twice.
        //i am not using this.

     }


     //if i take this code out, the images are not displayed and i cant view the thumbnails but i can click on
     //the area where the image is supposed to be  and I am able to view the image.
     for (int j = 0; j < pathes.Length; j++)
     {
         this.listView1.Items[j].ImageIndex = j;
     }


     this.listView1.View = View.LargeIcon;
     this.listView1.LargeImageList = imageList1;
     //this.listView1.Click += new EventHandler(Image_click);


 }

 //This was made so that user can click on the image to view the image at
 //but i am not sure whether this right thing to do? I originally used this for
 //my picture box.
 private void Image_click(object sender, EventArgs e)
 {

     listView1 = (ListView)sender;
     String thePath = ((string)((Control)sender).Tag);
     ImageViewer imageViewer = new ImageViewer(thePath);
     imageViewer.Show();
 }


//so i decided to this method instead.
private void listView1_MouseClick(object sender, MouseEventArgs e)
 {
     try
     {
         ListView.SelectedListViewItemCollection slvc = listView1.SelectedItems;

         string apath = slvc[0].ImageKey;
         ImageViewer iv = new ImageViewer(apath);
         iv.Show();

     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }

 }




I would also like to draw the thumbnails whilst maintaining the aspect ratio.Any advice on this please?

Thanks in advance.
AnswerRe: Listview Control problem - thumbnail display Pin
Saksida Bojan25-Feb-10 11:15
Saksida Bojan25-Feb-10 11:15 
GeneralRe: Listview Control problem - thumbnail display Pin
Eagle3226-Feb-10 4:09
Eagle3226-Feb-10 4:09 
QuestionERROR in starting service Pin
noamtzu0025-Feb-10 6:51
noamtzu0025-Feb-10 6:51 
AnswerRe: ERROR in starting service Pin
Saksida Bojan25-Feb-10 7:42
Saksida Bojan25-Feb-10 7:42 
GeneralRe: ERROR in starting service Pin
noamtzu0025-Feb-10 8:12
noamtzu0025-Feb-10 8:12 
GeneralRe: ERROR in starting service Pin
Saksida Bojan25-Feb-10 11:06
Saksida Bojan25-Feb-10 11:06 
AnswerRe: ERROR in starting service Pin
The Man from U.N.C.L.E.25-Feb-10 8:06
The Man from U.N.C.L.E.25-Feb-10 8:06 
GeneralRe: ERROR in starting service Pin
noamtzu0025-Feb-10 8:14
noamtzu0025-Feb-10 8:14 
GeneralRe: ERROR in starting service Pin
Wes Aday25-Feb-10 9:03
professionalWes Aday25-Feb-10 9:03 
GeneralRe: ERROR in starting service Pin
The Man from U.N.C.L.E.25-Feb-10 22:17
The Man from U.N.C.L.E.25-Feb-10 22:17 
Questionbehavior of Windows.Forms.Timer vs WM_TIMER Pin
manustone25-Feb-10 5:50
manustone25-Feb-10 5:50 
AnswerRe: behavior of Windows.Forms.Timer vs WM_TIMER Pin
Saksida Bojan25-Feb-10 6:20
Saksida Bojan25-Feb-10 6:20 
GeneralRe: behavior of Windows.Forms.Timer vs WM_TIMER Pin
manustone25-Feb-10 11:33
manustone25-Feb-10 11:33 
AnswerRe: behavior of Windows.Forms.Timer vs WM_TIMER Pin
Rob Philpott25-Feb-10 6:57
Rob Philpott25-Feb-10 6:57 
GeneralRe: behavior of Windows.Forms.Timer vs WM_TIMER Pin
manustone25-Feb-10 11:36
manustone25-Feb-10 11:36 
GeneralRe: behavior of Windows.Forms.Timer vs WM_TIMER Pin
Paulo Zemek26-Feb-10 3:02
Paulo Zemek26-Feb-10 3:02 
Questionfree c#.net slider without using javascript Pin
heidi stapel25-Feb-10 5:38
heidi stapel25-Feb-10 5:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.