It is my code:
this.fgTabela.ColumnSortOrderChanging += new NineRays.Windows.Forms.ColumnSortOrderChangingHandler(ColumnSortOrderChanging);
this.fgTabela.ColumnSortOrderChanged += new NineRays.Windows.Forms.ColumnSortOrderChangedHandler(ColumnSortOrderChanged);
private object[] sortOrderSelection = null;
private object focusedValue = null;
private Column sortColumn = null;
public void ColumnSortOrderChanging(object sender, Column column, SortOrder value, ref bool sorted)
{
sortColumn = column;
if ( fgTabela.Selected != null )
{
focusedValue = fgTabela.Selected.Value;
}
else
{
focusedValue = null;
}
// very slow code -- begin
NodeBase[] selection = fgTabela.Rows.GetSelection();
// very slow code -- end
if (selection != null && selection.Length > 0)
{
sortOrderSelection = new object[selection.Length];
for(int i=0; i< selection.Length; i++)
sortOrderSelection[i] = selection[i].Value;
}
else
{
sortOrderSelection = null;
}
}
public void ColumnSortOrderChanged(object sender, Column column)
{
if ( sortColumn == column )
{
if ( focusedValue != null )
{
NodeBase node = null;
for ( int i = 0; i < fgTabela.Rows.Items.Count; i++ )
{
node = fgTabela.Rows.Items[i];
if ( focusedValue.Equals(node.Value) )
{
// very slow code -- begin
fgTabela.Selected = node;
// very slow code -- end
break;
}
}
}
if ( sortOrderSelection != null )
{
NodeBase node = null;
for ( int i = 0; i < fgTabela.Rows.Items.Count; i++ )
{
node = fgTabela.Rows.Items[i];
if (Array.IndexOf(sortOrderSelection, node.Value) != -1)
{
// very slow code -- begin
node.Selected = true;
// very slow code -- end
break;
}
}
}
}
}