Hi,
I am using ultra grid . In that grid one of the column is drop down
vli = vl.ValueListItems.Add(dr["ColorName"].ToString(), " ");
vli.Appearance.BackColor = myColor;
In the drop down column ,i want to display only color and no text.Thats why i changed the
display member as " ".
Now I want to sort the column.If I set the display member as " ".I cant sort the column when
click on header because sorting is done based on display member text
Now I want to know how to override sort(),so that sorting is based on value member
ie here name of the colour
Is that possible?
plz help
thanks in advance
You can use a SortComparer to determine your own sort logic.
How to use:
E.g. column "Value" has string type but it's sorted as numeric.
1)
private class CustomComparer : IComparer { int IComparer.Compare(object x, object y) { UltraGridCell xCell = (UltraGridCell)x; UltraGridCell yCell = (UltraGridCell)y; double val1; double val2; double.TryParse(xCell.Value.ToString(), out val1); double.TryParse(yCell.Value.ToString(), out val2); return val1.CompareTo(val2); }
2. Set it to column:
UltraGridColumn valueCol = grid_.DisplayLayout.Bands[0].Columns["Value"]; valueCol.SortComparer = new CustomComparer();
Thanks, Alex.