Posted 15 October 2017, 4:08 pm EST
Hi,
I have few spreads in my application. I want to add some extra info in each cell. Since the tag property is already used for some other purpose, I created 2 extensions methods for setting and getting the extra info. I am using a dictionary object to store the cells and the extra info (using cell as the key).
Below is the comparer class I used for the dictionary.
public class CellComparer : IEqualityComparer<Cell>
{
public bool Equals(Cell x, Cell y)
{
//return x.Equals(y);
return (x == null && y == null) || (x != null && x.Equals(y));
}
public int GetHashCode(Cell obj)
{
//int hCode = obj.Column.Index ^ obj.Row.Index;
//return hCode.GetHashCode();
return obj.Row.Index ^ obj.Column.Index;
}
}
This code works as expected if there is no sorting implemented on the spread. But if we sort the spread, the comparer returns the wrong cell. Any idea how can we resolve this issue?