ImageGear .NET v25.2 - Updated
SortComparer Property (IImGearThumbnailCtl)
Example 




ImageGear.Windows.Forms Assembly > ImageGear.Windows.Forms.Thumbnails Namespace > IImGearThumbnailCtl Interface : SortComparer Property
Gets or sets IComparer used when Sort property is set to UserSort. You should provide a class implementing IComparer interface for custom sorting.
Syntax
'Declaration
 
Property SortComparer As IComparer
'Usage
 
Dim instance As IImGearThumbnailCtl
Dim value As IComparer
 
instance.SortComparer = value
 
value = instance.SortComparer
IComparer SortComparer {get; set;}
__property IComparer* get_SortComparer();
__property void set_SortComparer( 
   IComparer* value
);
property IComparer^ SortComparer {
   IComparer^ get();
   void set (    IComparer^ value);
}

Property Value

System.Collections.IComparer class object.
Example
public class CustomComparer : IComparer
    {
        public int Compare(Object a, Object b)
        {
            IImGearThumbnailItem item1 = (IImGearThumbnailItem)a;
            IImGearThumbnailItem item2 = (IImGearThumbnailItem)b;
            if (item1.Page.DIB.Height < item2.Page.DIB.Height)
            {
                return -1;
            }
            else if (item1.Page.DIB.Height > item2.Page.DIB.Height)
            {
                return 1;
            }
            else // equal
            {
                return 0;
            }
        }
    }
 
            // usage
            // .. in InitializeComponent
            this.thumbnailCtl.Sort = ImageGear.Windows.Forms.Thumbnails.ImGearSortOptions.UserSort;
            this.thumbnailCtl.SortComparer = new CustomComparer();
Public Class CustomComparer
	Implements IComparer
	Public Function Compare(a As [Object], b As [Object]) As Integer
		Dim item1 As IImGearThumbnailItem = DirectCast(a, IImGearThumbnailItem)
		Dim item2 As IImGearThumbnailItem = DirectCast(b, IImGearThumbnailItem)
		If item1.Page.DIB.Height < item2.Page.DIB.Height Then
			Return -1
		ElseIf item1.Page.DIB.Height > item2.Page.DIB.Height Then
			Return 1
		Else
			' equal
			Return 0
		End If
	End Function
End Class

		' usage
		' in InitializeComponent
		Me.thumbnailCtl.Sort = ImageGear.Windows.Forms.Thumbnails.ImGearSortOptions.UserSort
		Me.thumbnailCtl.SortComparer = New CustomComparer()
See Also

Reference

IImGearThumbnailCtl Interface
IImGearThumbnailCtl Members

Is this page helpful?
Yes No
Thanks for your feedback.