Click here to Skip to main content
15,914,642 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to create offline twitter ? Pin
annathor25-Feb-10 21:48
annathor25-Feb-10 21:48 
GeneralRe: How to create offline twitter ? Pin
OriginalGriff25-Feb-10 22:36
mveOriginalGriff25-Feb-10 22:36 
AnswerTry the Twitter API documentation Pin
The Man from U.N.C.L.E.25-Feb-10 22:21
The Man from U.N.C.L.E.25-Feb-10 22:21 
AnswerRe: How to create offline twitter ? Pin
Pete O'Hanlon26-Feb-10 9:56
mvePete O'Hanlon26-Feb-10 9:56 
QuestionMessage Removed Pin
25-Feb-10 20:00
NarVish25-Feb-10 20:00 
AnswerRe: 70-562 Microsoft .NET Framework 3.5, ASP.NET Application Development [modified] Pin
Saksida Bojan25-Feb-10 20:27
Saksida Bojan25-Feb-10 20:27 
Questionhow to write data into a text file from a console application? Pin
gouthami chintala25-Feb-10 19:58
gouthami chintala25-Feb-10 19:58 
AnswerRe: how to write data into a text file from a console application? Pin
Saksida Bojan25-Feb-10 20:20
Saksida Bojan25-Feb-10 20:20 
Questiontwitter Pin
anshach25-Feb-10 19:57
anshach25-Feb-10 19:57 
AnswerRe: twitter Pin
Harvey Saayman25-Feb-10 20:16
Harvey Saayman25-Feb-10 20:16 
Questionhow to read a html file into console Pin
ramyakrishna k25-Feb-10 19:57
ramyakrishna k25-Feb-10 19:57 
AnswerRe: how to read a html file into console Pin
Saksida Bojan25-Feb-10 20:19
Saksida Bojan25-Feb-10 20:19 
JokeRe: how to read a html file into console Pin
Harvey Saayman25-Feb-10 20:21
Harvey Saayman25-Feb-10 20:21 
AnswerRe: how to read a html file into console Pin
Luc Pattyn25-Feb-10 22:25
sitebuilderLuc Pattyn25-Feb-10 22:25 
QuestionUse Mdi from User Control? [modified] Pin
Pawan Kiran25-Feb-10 19:53
Pawan Kiran25-Feb-10 19:53 
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 

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.