471,594 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

Update Pictures in ImageList Component

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
2 4521
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
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.

Similar topics

reply views Thread by alex n | last post: by
2 posts views Thread by Bob C. | last post: by
2 posts views Thread by Xarky | last post: by
6 posts views Thread by Stephen Costanzo | last post: by
5 posts views Thread by Vittorio Pavesi | last post: by
6 posts views Thread by henrycortezwu | last post: by
reply views Thread by gene kelley | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.