RasterImageListSelectionMode Enumeration

Summary

Values for the RasterImageList.SelectionMode property.

Syntax

C#
C++/CLI
C++
public enum RasterImageListSelectionMode 
public enum class RasterImageListSelectionMode : public System.Enum, System.IComparable, System.IConvertible, System.IFormattable   
public: 
   enum class RasterImageListSelectionMode sealed 

Members
ValueMemberDescription
0NoneAutomatic selection is disabled, selection is manual
1SingleAutomatic selection of single items is enabled
2MultiAutomatic selection of multiple items is enabled. The user can select multiple items using the mouse and the CTRL and SHIFT keys.

Remarks

Specifies whether automatic item selection is allowed. If automatic item selection is enabled, items are automatically selected and de-selected when the user clicks on them using the mouse.

Example

C#
using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
 
class MyForm5 : Form 
{ 
   RasterImageList imageList; 
   RasterCodecs codecs; 
 
   public MyForm5(string title) 
   { 
      Text = title; 
 
      // Set the size of the form 
      Size = new Size(400, 200); 
 
      // Create a new RasterImageList control 
      imageList = new RasterImageList(); 
      imageList.Dock = DockStyle.Fill; 
      imageList.SelectionMode = RasterImageListSelectionMode.Single; 
      imageList.Size = Size; 
      Controls.Add(imageList); 
      imageList.BringToFront(); 
 
      codecs = new RasterCodecs(); 
 
      // Create three items 
      string imagesPath = LEAD_VARS.ImagesDir; 
 
      for (int i = 0; i < 3; i++) 
      { 
         // Load the image 
         int 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 item 
         if (i == 0) 
            item.Selected = true; 
 
         // Add the item to the image list 
         imageList.Items.Add(item); 
      } 
 
 
      // Use manual selection 
      imageList.SelectionMode = RasterImageListSelectionMode.None; 
 
      // Add a handler to the MouseDown event 
      imageList.MouseDown += new MouseEventHandler(rasterImageList_MouseDown); 
 
      // Add the RasterImageList to the control collection. 
      Controls.Add(imageList); 
   } 
 
   private void rasterImageList_MouseDown(object sender, MouseEventArgs e) 
   { 
      RasterImageList imageList = sender as RasterImageList; 
 
      // Check if we are in manual selection mode and if this is a left button click 
      if (imageList.SelectionMode == RasterImageListSelectionMode.None && 
         e.Button == MouseButtons.Left) 
      { 
         // Yes, get the item under the cursor position 
         RasterImageListItem item = imageList.HitTest(e.X, e.Y); 
 
         // If not already selected, select this item 
         if (item != null && !item.Selected) 
         { 
            imageList.BeginUpdate(); 
 
            // First, de-select any items 
            imageList.SelectAll(false); 
 
            // Now select this item 
            item.Selected = true; 
 
            imageList.EndUpdate(); 
 
            item.Invalidate(); 
         } 
      } 
   } 
} 
 
public void RasterImageList_SelectionMode(string title) 
{ 
   MyForm5 form = new MyForm5(title); 
   form.ShowDialog(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 

Requirements

Target Platforms

See Also

Reference

Leadtools.WinForms Namespace

Help Version 22.0.2023.2.9
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.WinForms Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.