AD
Administrator
Syncfusion Team
October 1, 2003 12:58 PM UTC
Right now there is no easy way.
But, I'll add some method overloads to GridData that will let you pass in a custom comparer for the styles/values.
With these changes you can then do the following:
1) Call SortByColumn with custom comparer object
this.gridControl1.Data.SortByColumn(col,(ListSortDirection)this.gridControl1[0, col].Tag, new CustomComparer());
2) This is how such comparer object can look like.
public class CustomComparer : IComparer
{
#region IComparer Members
public int Compare(object x, object y)
{
GridStyleInfoStore style1 = x as GridStyleInfoStore;
GridStyleInfoStore style2 = y as GridStyleInfoStore;
object val1 = null;
object val2 = null;
if (style1 != null)
val1 = style1.GetValue(GridStyleInfoStore.CellValueProperty);
if (style2 != null)
val2 = style2.GetValue(GridStyleInfoStore.CellValueProperty);
if (val1 == null && val2 == null)
return 0;
else if (val1 == null)
return -1;
else if (val2 == null)
return 1;
else
{
try
{
// You could now implement here your own custom compare technique ...
if (val1 is IComparable && val2 is IComparable)
{
int r = ((IComparable) val1).CompareTo(val2);
return r;
}
}
catch (Exception ex)
{
}
return val1.ToString().CompareTo(val2.ToString());
}
}
#endregion
}
Change will be in the next builds 1.6.1.8 and/or 2.0.0.x next time we release a new build.
Stefan