Gets or sets a value indicating whether to auto dispose the old image when a new image is set into the items of this ImageList.
[CategoryAttribute("Behavior")][DescriptionAttribute("Automatically disposes the item RasterImage objects when them item is removed from the control or when the control is disposed.")]public bool AutoDisposeImages {get; set;}
<CategoryAttribute("Behavior")><DescriptionAttribute("Automatically disposes the item RasterImage objects when them item is removed from the control or when the control is disposed.")>Public Property AutoDisposeImages As Boolean
[CategoryAttribute("Behavior")][DescriptionAttribute("Automatically disposes the item RasterImage objects when them item is removed from the control or when the control is disposed.")]public:property bool AutoDisposeImages {bool get();void set ( bool );}
true if the Leadtools.RasterImage object in the items of this ImageList is automatically disposed when a new image is set; otherwise, false. Default value is true.
When you change the value of this property, this control iterate all the items inside it and set the RasterImageListItem.AutoDisposeImages value of each item that is of type RasterImageListItem accordingly. For more information, refer to RasterImageListItem.AutoDisposeImages.
Imports Leadtools.Windows.ControlsImports Leadtools.CodecsImports LeadtoolsPublic Sub ImageList_AutoDisposeImages(ByVal imageList As ImageList)' Make sure the AutoDisposeImages property is set to trueimageList.AutoDisposeImages = TrueMessageBox.Show("Removing an item then accessing its image with AutoDisposeImages set to true")' Remove the first itemDim item As RasterImageListItem = CType(imageList.Items(0), RasterImageListItem)imageList.Items.RemoveAt(0)' Try to save this item's image into a disk file' This will throw an exception since the item image has been dispose' as a result of having the AutoDisposeImages false set to trueDim codecs As New RasterCodecs()Trycodecs.Save(item.Image, Path.Combine(LEAD_VARS.ImagesDir, "Test.jpg"), RasterImageFormat.Jpeg, 24)MessageBox.Show("Image saved correctly")Catch ex As ExceptionMessageBox.Show(ex.Message)End TryMessageBox.Show("Removing an item then accessing its image with AutoDisposeImages set to false")' Now remove the next item, this time make sure to set the' AutoDisposeImages property to false before you remove the item' from the control collectionitem = CType(imageList.Items(0), RasterImageListItem)imageList.AutoDisposeImages = FalseimageList.Items.RemoveAt(0)imageList.AutoDisposeImages = True' Try to save this item's image into a disk file' This time, this should work correcly since the control did not dispose' the item image.Trycodecs.Save(item.Image, Path.Combine(LEAD_VARS.ImagesDir, "Test.jpg"), RasterImageFormat.Jpeg, 24)MessageBox.Show("Image saved correctly")Catch ex As ExceptionMessageBox.Show(ex.Message)End Trycodecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools.Help;using Leadtools.Windows.Controls;using Leadtools;using Leadtools.Codecs;public void ImageList_AutoDisposeImages(ImageList imageList){// Make sure the AutoDisposeImages property is set to trueimageList.AutoDisposeImages = true;MessageBox.Show("Removing an item then accessing its image with AutoDisposeImages set to true");// Remove the first itemRasterImageListItem item = imageList.Items[0] as RasterImageListItem;imageList.Items.RemoveAt(0);// Try to save this item's image into a disk file// This will throw an exception since the item image has been dispose// as a result of having the AutoDisposeImages false set to trueRasterCodecs codecs = new RasterCodecs();try{codecs.Save(item.Image, Path.Combine(LEAD_VARS.ImagesDir, "Test.jpg"), RasterImageFormat.Jpeg, 24);MessageBox.Show("Image saved correctly");}catch(Exception ex){MessageBox.Show(ex.Message);}MessageBox.Show("Removing an item then accessing its image with AutoDisposeImages set to false");// Now remove the next item, this time make sure to set the// AutoDisposeImages property to false before you remove the item// from the control collectionitem = imageList.Items[0] as RasterImageListItem;imageList.AutoDisposeImages = false;imageList.Items.RemoveAt(0);imageList.AutoDisposeImages = true;// Try to save this item's image into a disk file// This time, this should work correcly since the control did not dispose// the item image.try{codecs.Save(item.Image, Path.Combine(LEAD_VARS.ImagesDir, "Test.jpg"), RasterImageFormat.Jpeg, 24);MessageBox.Show("Image saved correctly");}catch(Exception ex){MessageBox.Show(ex.Message);}codecs.Dispose();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
|
Products |
Support |
Feedback: AutoDisposeImages Property (ImageList) - Leadtools.Windows.Controls |
Introduction |
Help Version 19.0.2017.3.22
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.