This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Tuesday, January 24, 2012 2:02:46 AM(UTC)
Groups: Registered
Posts: 7
I'm trying to use an ImageList to show pictures along the top of the window, and what I'd like to do is center the pictures as I load them.
The user is most likely to only have a small number of pictures in it, and I'd like to have that show mid-screen instead of the left edge.
I've looked but don't see this type of property, but it can't hurt to ask!
Thanks
#2
Posted
:
Tuesday, January 24, 2012 10:41:39 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
There isn't any "align center" setting per se, but I've come up with a workaround using the
RasterImageList.ItemSpacingSize property. This property adds a certain amount of space around each image item.
To calculate the spacing so that the images are centered within the Image List you would compute the spacing
width as: ( ImageList.Width - (ImageList.ItemSize.Width * number of images) ) / (2 * number of images).
There are couple tricky points here:
1. The spacing is added to each side of the image, so the images on the far left and far right will be closer
to the window edges than the images they're adjacent to. You could probably fix this by changing the size and
position of the container rectangle for the ImageList.
2. The ImageList.ItemSize property seems to be independent of the size set by ImageList.ItemImageSize, so
that's why it's used in the calculation instead.
3. In order to access ImageList.ItemSize, it needs to be called after at least one image has been added to the
ImageList, otherwise the property won't be available.
The code from the RasterImageList Example with the ItemImageSpacing property set to center 4 images in
the window is attached with this message.
Here's the original page the code is from:
http://www.leadtools.com...rms.rasterimagelist.htmlSome other things to look at for customizing the image item drawing is the "OwnerDraw" property and the "DrawItem"
event:
http://www.leadtools.com...agelist~drawitem_ev.html
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.