I have a TreeListView control where each root item is expandable, containing an arbitrary number of subnodes. The background color should alternate only at the root level so that all subnodes are of the same background color. If I use a RowFormatter it works as long as it's not sorted by clicking the header.
private void FormatRow(OLVListItem item)
{
var node = (BaseNode)item.RowObject;
var root = node.GetRoot();
if (root == null) return;
var alternate = Model.GetNodeIndex(root) % 2 == 1;
item.BackColor = alternate ? Color.FromArgb(240, 240, 240) : Color.White;
}
How do I get the object's ACTUAL index in the tree, not the index in the underlying data?