Hi,
I need do a custom sort on a column, which display images. Could you please let me know how I do that, and if possible provide me with a sample.
I am using the SourceGrid3.Grid class.
Thanks
Biju Nair
figured it out myself
Implemented the IComparer interface like :
public class ImageComparer : IComparer {
// Calls CaseInsensitiveComparer.Compare int IComparer.Compare( Object x, Object y ) { SourceGrid3.Cells.Real.Image imgX = (SourceGrid3.Cells.Real.Image)x; SourceGrid3.Cells.Real.Image imgY = (SourceGrid3.Cells.Real.Image)y; return( (new CaseInsensitiveComparer()).Compare(imgX.Tag.ToString(), imgY.Tag.ToString()) ); }
}
and set the SortComparer for the SourceGrid3.Cells.Real.ColumnHeader object to an instance of the above.
What I am doing here is using the Tag to store the data to compare for the column with images.
Useful when you want to display images for boolean columns e.g. show a 'tick' image if true else display a 'cross' image if false.
Log in to post a comment.
Hi,
I need do a custom sort on a column, which display images. Could you please let me know how I do that, and if possible provide me with a sample.
I am using the SourceGrid3.Grid class.
Thanks
Biju Nair
Hi,
figured it out myself
Implemented the IComparer interface like :
public class ImageComparer : IComparer
{
// Calls CaseInsensitiveComparer.Compare
int IComparer.Compare( Object x, Object y )
{
SourceGrid3.Cells.Real.Image imgX = (SourceGrid3.Cells.Real.Image)x;
SourceGrid3.Cells.Real.Image imgY = (SourceGrid3.Cells.Real.Image)y;
return( (new CaseInsensitiveComparer()).Compare(imgX.Tag.ToString(), imgY.Tag.ToString()) );
}
}
and set the SortComparer for the SourceGrid3.Cells.Real.ColumnHeader object to an instance of the above.
What I am doing here is using the Tag to store the data to compare for the column with images.
Useful when you want to display images for boolean columns e.g. show a 'tick' image if true else display a 'cross' image if false.
Biju Nair