I have two columns in a Grid. The 1st column of type image and a second column of text that represents the image of the first column. I wish when I group the first column of the grouping is done by hidden column. There is how to do?
my English is very weak, do not intend much. I created the class below:Public Class MyComparer Implements IComparer #Region "IComparer Members" Private Function IComparer_Compare(x As Object, y As Object) As Integer Implements IComparer.Compare Dim xCell As UltraGridCell = TryCast(x, UltraGridCell) Dim yCell As UltraGridCell = TryCast(y, UltraGridCell) If xCell = yCell Then Return 0 End If If xCell Is Nothing Then Return 1 ElseIf yCell Is Nothing Then Return -1 End If Dim xString As String = xCell.Row.Cells("text Column").Text Dim yString As String = yCell.Row.Cells("text Column").Text Return xString.CompareTo(yString) End Function #End RegionEnd Class
in which event and how I'll make this comparison
All you have to do is create an IComparer for the image column that compares the cells based on the values in the text column. Then you set the SortComparer on the image column to an instance of your IComparer class.
The IComparer class would look something like this:
public class MyComparer : IComparer { #region IComparer Members int IComparer.Compare(object x, object y) { UltraGridCell xCell = x as UltraGridCell; UltraGridCell yCell = y as UltraGridCell; if (xCell == yCell) return 0; if (xCell == null) return 1; else if (yCell == null) return -1; string xString = xCell.Row.Cells["text Column"].Text; string yString = yCell.Row.Cells["text Column"].Text; return xString.CompareTo(yString); } #endregion }