Leadtools.Windows.Controls Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.03.25
ImageList Class
See Also  Members   Example 
Leadtools.Windows.Controls Namespace : ImageList Class





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

Syntax

Visual Basic (Declaration) 
Public Class ImageList 
   Inherits ListBox
   Implements IGeneratorHost, IElement 
Visual Basic (Usage)Copy Code
Dim instance As ImageList
C# 
public class ImageList : ListBox, IGeneratorHost, IElement  
Managed Extensions for C++ 
public __gc class ImageList : public ListBox, IGeneratorHost, IElement  
C++/CLI 
public ref class ImageList : public ListBox, IGeneratorHost, IElement  
XAML Object Element Usage 

<ImageList .../>

Example

This example creates an instance of an ImageList control and adds it to a form. Next, three images are loaded to populate the control.

Visual BasicCopy Code
Private Class MyWindow1 : Inherits Window
   Public imageList As ImageList
   Public Sub New(ByVal title As String)
      title = title
      ' Set the size of the window
      Width = 400
      Height = 200

      ' Create a new ImageList control.
      imageList = New ImageList()
      imageList.Width = Double.NaN
      imageList.Height = Double.NaN

      imageList.Items.SortDescriptions.Clear()
      imageList.Background = New RadialGradientBrush(Colors.DarkGray, Colors.LightGray)
      imageList.Items.SortDescriptions.Add(New SortDescription("Text", ListSortDirection.Ascending))

      imageList.BorderThickness = New Thickness(5, 5, 5, 5)


      ' Create three items
      Dim imagesPath As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\"

      For i As Integer = 0 To 2
         ' Load the image
         Dim index As Integer = i + 1
         Dim imageFileName As String = imagesPath & "Image" & index.ToString() & ".jpg"

         Dim item As ImageListItem = New ImageListItem(New BitmapImage(New Uri(imageFileName)), "item" & index.ToString())

         ' Select the first item
         If i = 0 Then
            item.IsSelected = True
         End If

         ' Add the item to the image list
         imageList.Items.Add(item)
      Next i

      ' Add the ImageList to the Window.
      Content = imageList
   End Sub
End Class

Public Sub ImageList_ImageList(ByVal title As String)
   Dim window As MyWindow1 = New MyWindow1(title)
   window.ShowDialog()
End Sub
C#Copy Code
class MyWindow1 : Window 

   public ImageList imageList; 
   public MyWindow1(string title) 
   { 
      Title = title; 
      // Set the size of the window 
      Width = 400; 
      Height = 200; 
 
      // Create a new ImageList control. 
      imageList = new ImageList(); 
      imageList.Width = Double.NaN; 
      imageList.Height = Double.NaN; 
 
      imageList.Items.SortDescriptions.Clear(); 
      imageList.Background = new RadialGradientBrush(Colors.DarkGray, Colors.LightGray); 
      imageList.Items.SortDescriptions.Add(new SortDescription("Text", ListSortDirection.Ascending)); 
 
      imageList.BorderThickness = new Thickness(5, 5, 5, 5); 
 
 
      // Create three items 
      string imagesPath = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\"; 
 
      for (int i = 0; i < 3; i++) 
      { 
         // Load the image 
         int index = i + 1; 
         string imageFileName = imagesPath + "Image" + index.ToString() + ".jpg"; 
 
         ImageListItem item = new ImageListItem(new BitmapImage(new Uri(imageFileName)), "item" + index.ToString()); 
 
         // Select the first item 
         if (i == 0) 
            item.IsSelected = true; 
 
         // Add the item to the image list 
         imageList.Items.Add(item); 
      } 
 
      // Add the ImageList to the Window. 
      Content = imageList; 
   } 

 
public void ImageList_ImageList(string title) 

   MyWindow1 window = new MyWindow1(title); 
   window.ShowDialog(); 
}

Remarks

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

An ImageList control allows you to display a list of items with text and a BitmapSource. For example, the Windows Explorer in Thumbnails mode is similar in appearance to an ImageList control. The ImageListItem class represents an item within an ImageList control. The items that are displayed in the list can be shown using one of the ImageListViewStyle styles.
The ImageList 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 ListBox control. Additionally, the user can activate selected items to perform a task. For example, you could use an ImageList 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.

The ImageList provides a large number of properties that provide flexibility in appearance and behavior. The ViewStyle property allows the way in which items are displayed to be changed. Items are added and removed from the ImageList through the Items property. You may want to provide functionality when the user right-clicks an item. To determine the item which is being clicked, use the HitTest method, or manually calculate which item is displayed in what position using the ItemSize property. Sometimes you want to display a specific item for the user to view. Call the EnsureVisible method to ensure that the specific item is in the visible area of the control.


Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Media.Visual
            System.Windows.UIElement
               System.Windows.FrameworkElement
                  System.Windows.Controls.Control
                     System.Windows.Controls.ItemsControl
                        System.Windows.Controls.Primitives.Selector
                           System.Windows.Controls.ListBox
                              Leadtools.Windows.Controls.ImageList

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family

See Also