how to scrolling through "stacked" images?
-
Does a control exist where I can load it with any number of images (one on top of the other) and then vertically scroll through them for viewing? My images will all be the same width but not the same height. I was thinking to host a webpage in my app and have local tags for the images but I don’t want the overhead. Any other ideas you would be great to have. Thanks!
-
Does a control exist where I can load it with any number of images (one on top of the other) and then vertically scroll through them for viewing? My images will all be the same width but not the same height. I was thinking to host a webpage in my app and have local tags for the images but I don’t want the overhead. Any other ideas you would be great to have. Thanks!
This would be a simple owner-drawn
ListBox
, for which several articles on this site already cover what you need to do (or alternatives, at least). Read ImageListBox - exposing localizable custom object collection as a property[^]. If covers a few things you didn't mention requiring, but the source will give you an idea. Basically, you just setDrawMode
toDrawMode.OwnerDrawVariable
(since they could be different heights, as you mentioned), and handle both theMeasureItem
andDrawItem
events. If you would actually be better, however, to extendListBox
with your own implementation (perhaps something likeImageListBox
) that overrides theDrawMode
property (always returnsDrawMode.OwnerDrawVariable
but does nothing or throws aNotSupportedException
or something in theset
accessor) and theOnMeasureItem
andOnDrawItem
methods (don't forget to call the base class's implementation so that events are fired). This is a far better approach because you won't have to implement all this code again every time you want to have anImageListBox
-like control, and overriding methods is faster than handling events. It's all about encapsulation.Microsoft MVP, Visual C# My Articles