Sorting Property


Gets or sets the sort order for items in the control.


public SortOrder Sorting { get; set; } 
property SortOrder Sorting { 
   SortOrder get(); 
   void set (    SortOrder ); 
   property SortOrder^ Sorting 
      SortOrder^ get() 
      void set(SortOrder^ value) 

Property Value

One of the SortOrder values. The default is SortOrder.None.


The Sorting property allows you to specify whether or not items are sorted in the RasterImageList control. By default, no sorting is performed. When the Sorting property is set to SortOrder.Ascending or SortOrder.Descending, the items in the RasterImageList are sorted automatically in ascending alphabetical order (when the property is set to SortOrder.Ascending) or descending alphabetical order (when the property is set to SortOrder.Descending). You can use this property to automatically sort items that are displayed in your RasterImageList control to make it easier for users to find items when a large number of items are available. By default items are sorted alphabetically according to the Text property of each item.

After you change the Sorting property, call the Sort method to re-sort the items in the control.

The Sorting property is dependent on the value of the Sorter property.

You can setup your own sorting by providing a custom System.Collections.IComparer object using the Sorter property.


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 
      // Add the RasterImageList to the control collection. 
   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( 
      e.Graphics.FillRectangle(b, rc); 
public void RasterImageList_RasterImageList(string title) 
   MyForm1 form = new MyForm1(title); 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 


Target Platforms

See Also


RasterImageList Class

RasterImageList Members

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.