Gets or sets the object that contains data about this RasterImageListItem.
public object Tag { get; set; } public:property Object^ Tag{Object^ get()void set(Object^ value)}
An System.Object that contains data about this RasterImageListItem. The default value is a null reference (Nothing in VB).
Any System.Object derived type can be assigned to this property.
You can use this property to associate your own user-defined data with an item.
This example creates and populates a RasterImageList control with a few items. It then associates each item with a user-defined object. When the selected item is changed by the user interface, the corresponding user data is pulled from the selected item and displayed in a message box.
using Leadtools.WinForms;using Leadtools;using Leadtools.Codecs;private class UserData{public int Number;public string Text;}public void RasterImageListItem_Tag(RasterImageList imageList){// Create a new RasterImageList control.imageList.Bounds = new Rectangle(new Point(0, 0), new Size(300, 200));// Sort the items in the list in ascending order.imageList.Sorting = SortOrder.Ascending;// Initialize the RasterCodecs classRasterCodecs codecs = new RasterCodecs();// Clear existing itemsimageList.Items.Clear();// Create three itemsstring imagesPath = LEAD_VARS.ImagesDir;for (int i = 0; i < 3; i++){// Load the imageint index = i + 1;string imageFileName = Path.Combine(imagesPath, @"ImageProcessingDemo\Image" + index.ToString() + ".cmp");RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);RasterImageListItem item = new RasterImageListItem(image, 1, "Item" + index.ToString());// Select the first itemif (i == 0)item.Selected = true;// Add the user dataUserData data = new UserData();data.Number = index;data.Text = "This is data number " + index.ToString();item.Tag = data;// Add the item to the image listimageList.Items.Add(item);}// Add a handler to the SelectedIndexChanged eventimageList.SelectedIndexChanged += new EventHandler(imageList_SelectedIndexChanged);}private void imageList_SelectedIndexChanged(object sender, EventArgs e){// User has selected an item from the RasterImageList control.// Get the user data associated with the currently selected item and// show it in a message boxRasterImageList imageList = sender as RasterImageList;// Get the selected item(s)RasterImageListItemCollection selectedItems = imageList.SelectedItems;if (selectedItems != null && selectedItems.Count == 1){RasterImageListItem item = selectedItems[0];// Load the image in its original size and set it in the viewerUserData data = item.Tag as UserData;string msg = string.Format("Number = {0}{1}Text = {2}", data.Number, Environment.NewLine, data.Text);MessageBox.Show(msg);}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
