RasterImageList Class

Summary

Represents an image list control, which displays a collection of items that can be displayed using one of the RasterImageListViewStyle styles.

Syntax

C#
C++/CLI
[DefaultEventAttribute("SelectedIndexChanged")] 
[DefaultPropertyAttribute("ViewStyle")] 
public class RasterImageList : Control 
public: 
   [DefaultEventAttribute(L"SelectedIndexChanged"),  
   DefaultPropertyAttribute(L"ViewStyle")] 
   ref class RasterImageList : Control 

Remarks

The RasterImageList control lets you display and manipulate a list of images. The RasterImageList control contains a list of items that can be used to view thumbnails of Leadtools.RasterImage objects.

A RasterImageList control allows you to display a list of items with text and an Leadtools.RasterImage. For example, the Windows Explorer in Thumbnails mode is similar in appearance to a RasterImageList control. The RasterImageListItem class represents an item within a RasterImageList control. The items that are displayed in the list can be shown using one of the RasterImageListViewStyle styles. RasterImageList supports single or multiple item selection. The multiple selection feature lets the user select from a list of items in a way similar to a System.Windows.Forms.ListBox control. Additionally, the user can activate selected items to perform a task. For example, you could use a RasterImageList control to display a list of files that the application can then open and utilize. The user can select the files to open and then double-click them to activate the items and open the files in the application.

RasterImageList provides a large number of properties that provide flexibility in appearance and behavior. The ViewStyle property allows you to change the way in which items are displayed. Items are added and removed from the RasterImageList through the Items property. The Items property allows you to access the RasterImageListItemCollection of the control, which provides methods for manipulating the items in the control. When your control contains a large number of items, it is often easier for the user to see them in a sorted list. You can use the Sorting property to sort the items alphabetically.

In addition to the many properties that are available for a RasterImageList control, there are methods and events that your application can use to provide additional capabilities to the RasterImageList. The BeginUpdate and EndUpdate methods allow you to add many items to a RasterImageList without displaying the repainting of the control each time an item is added, thus improving performance. You you may want to provide functionality when the user right-clicks an item. To determine the item which is being clicked, you can use the HitTest method or you can manually calculate what item is displayed in what position using the GetItemRectangle method. Sometimes you want to display a specific item to the user to view. The EnsureVisible method can be called to ensure that the specific item is in the visible area of the control.

When the user changes the selected items with the keyboard or mouse, the control will fire the SelectedIndexChanged event. You can then read the SelectedItems to get a list of the currently selected items.

NOTE: For automatic generation of thumbnails from files stored on your computer, see RasterThumbnailBrowser.

Example

This example creates an instance of a RasterImageList control and adds it to a form Next three images are loaded to populate the control. The PaintBackground event is used to fill the background of a control with a gradient brush.

C#
using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
 
class MyForm1 : Form 
{ 
   public RasterImageList imageList; 
   public MyForm1(string title) 
   { 
      Text = title; 
 
      // Set the size of the form 
      Size = new Size(400, 200); 
 
      // Create a new RasterImageList control. 
      imageList = new RasterImageList(); 
      imageList.Bounds = new Rectangle(new Point(0, 0), Size); 
 
      imageList.Sorting = SortOrder.Ascending; 
      imageList.BorderStyle = BorderStyle.None; 
      imageList.DoubleBuffer = true; 
      imageList.Dock = DockStyle.Fill; 
      RasterPaintProperties paintProperties = imageList.PaintProperties; 
      paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic; 
      imageList.PaintProperties = paintProperties; 
      imageList.EnableKeyboard = true; 
      imageList.UseDpi = true; 
 
      // Add a handler to the PaintBackground event 
      imageList.PaintBackground += new PaintEventHandler(rasterImageList_PaintBackground); 
 
      RasterCodecs 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); 
      } 
 
      // Add the RasterImageList to the control collection. 
      Controls.Add(imageList); 
   } 
 
 
   private void rasterImageList_PaintBackground(object sender, PaintEventArgs e) 
   { 
      // Get the image list control 
      RasterImageList imageList = sender as RasterImageList; 
 
      // Fill the background with a gradient brush 
      Rectangle rc = imageList.ClientRectangle; 
 
      Brush b = new LinearGradientBrush( 
         rc, 
         Color.Bisque, 
         Color.White, 
         LinearGradientMode.Vertical); 
      e.Graphics.FillRectangle(b, rc); 
      b.Dispose(); 
   } 
 
} 
 
public void RasterImageList_RasterImageList(string title) 
{ 
   MyForm1 form = new MyForm1(title); 
   form.ShowDialog(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 

Requirements

Target Platforms

See Also

Reference

RasterImageList Members

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.