Seems that you've not received my mail.
Try to understand here:
The problem you mentioned in that you've not correctly understand visiblity of columns and layers:
1. to find column (what might be invisible), use
2. to check visiblity of column use Column.Visible or existance of column in Columns.VisibleColumns array.
3. Columns.GetColumnFromCellIndex(index) is more safe analoque of Columns.VisibleColumns[index]
4. GetFieldNameFromCellIndex is more safe analogue of
Column col = VisibleColumns[cellIndex];
return col.FieldName;
I've noticed that you're using column cache to change cell values, but why you do not use direct ways: Column.SeCellValue(Node) or Node.SetValue(Column)?
You can use more faster way if will use following way:
//here is my vision of your problem solution,
//context of methods below - control derived from FlyGrid
//without invalidation
private void ChangeCellValue(Node node, Column col, object value)
{
ChangeCellValue(node, col, value, false);
}
//with/without invalidation
private void ChangeCellValue(Node node, Column col, object value, bool invalidate)
{
//this is a index to place data into internal data representation
// - directly to node.Value that containing array of data to display in cells
// as some columns can't be visible, direct way uses columns map to
//create own map that points to internal data
int cellIndex = GetColumnIndexForCellValues(col);
if (cellIndex != -1)
{
object[] cellValues = node.Value as object[];
cellValues[cellIndex] = value;
if (invalidate)
this.ActiveRootPort.InvalidateCell(node, col);
}
}
private int GetColumnIndexForCellValues(Column col)
{
return Array.IndexOf(ColumnCache, col);
}
private Column[] columnCache = null;
internal Column[] ColumnCache
{
get
{
if (columnCache == null)
BuildColumnCache();
return columnCache;
}
}
//this method you can use when rebuild columns - restructure data in the //grid or change layout (not when columns reodered, become invisible or hidden)
public void ResetColumnCache()
{
columnCache = null;
}
private void BuildColumnCache()
{
ArrayList map = this.Columns.GetColumnMap();
columnCache = new Column[map.Count];
for(int i=0; i < columnCache.Length; i++)
{
ColumnFieldTag cft = map[i] as ColumnFieldTag;
columnCache[i] = cft.Column;
}
}