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

Update Pictures in ImageList Component

P: n/a
I'm using a ListView control to display pictures similarly to how
Windows Explorer displays pictures in "Thumbnails" view. The images are
stored in an ImageList component. I would like to provide the ability
to rotate the images and I'm having some issues.

Basically, what I've tried is:

lstViewImages.LargeImageList.Images[ItemIndex].RotateFlip(RotateFlipType.Rotate90FlipNone);
lstViewImages.Update();

And:

imageListThumbNails.Images[ItemIndex].RotateFlip(RotateFlipType.Rotate90FlipNone);
lstViewImages.Update();

Obviously, the first approach accesses the ImageList component through
the ListView control, whereas the second approach accesses the ImageList
component directly. The code should, in theory, rotate the image in the
ImageList component; however, viewing the image after calling the
RotateFlip() method displays the image in its original position.

I considered removing the original image and adding it again, but that
wasn't a viable solution because the imageListThumbNails.Images
collection does not provide an Insert() method that I could use to
specify the exact index that I wish the update image to be inserted. In
other words, I could only Add() the image to the end of the collection,
which would reorder everything.

Am I doing something wrong or is there another approach I should look into?

Thank you in advance,

--
Sean
Dec 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Sean,

The ImageList.Images collection's indexer is read/write:

Image image = imageListThumbNails.Images[ItemIndex];
image.RotateFlip(RotateFlipType.Rotate90FlipNone);

// refresh the image within the ImageList
imageListThumbNails.Images[ItemIndex] = image;

// Update only works if some region has been invalidated.
// Calling Refresh does both: invalidate and update
lstViewImages.Refresh();

--
Dave Sexton

"senfo" <en**********@yahoo.comI-WANT-NO-SPAMwrote in message
news:uh*************@TK2MSFTNGP02.phx.gbl...
I'm using a ListView control to display pictures similarly to how Windows
Explorer displays pictures in "Thumbnails" view. The images are stored in
an ImageList component. I would like to provide the ability to rotate the
images and I'm having some issues.

Basically, what I've tried is:

lstViewImages.LargeImageList.Images[ItemIndex].RotateFlip(RotateFlipType.Rotate90FlipNone);
lstViewImages.Update();

And:

imageListThumbNails.Images[ItemIndex].RotateFlip(RotateFlipType.Rotate90FlipNone);
lstViewImages.Update();

Obviously, the first approach accesses the ImageList component through the
ListView control, whereas the second approach accesses the ImageList
component directly. The code should, in theory, rotate the image in the
ImageList component; however, viewing the image after calling the
RotateFlip() method displays the image in its original position.

I considered removing the original image and adding it again, but that
wasn't a viable solution because the imageListThumbNails.Images collection
does not provide an Insert() method that I could use to specify the exact
index that I wish the update image to be inserted. In other words, I
could only Add() the image to the end of the collection, which would
reorder everything.

Am I doing something wrong or is there another approach I should look
into?

Thank you in advance,

--
Sean

Dec 13 '06 #2

P: n/a
Dave Sexton wrote:
Hi Sean,

The ImageList.Images collection's indexer is read/write:

Image image = imageListThumbNails.Images[ItemIndex];
image.RotateFlip(RotateFlipType.Rotate90FlipNone);

// refresh the image within the ImageList
imageListThumbNails.Images[ItemIndex] = image;

// Update only works if some region has been invalidated.
// Calling Refresh does both: invalidate and update
lstViewImages.Refresh();
That did the trick. I'm not sure how I missed the indexer being
read/write. Also, thank you for pointing out the Refresh() method. I
hadn't realized that.

Thank you very much,

--
Sean
Dec 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.