Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13216 |

    I have written code to export data to Excel. I sort columns according to the VisibleIndex property. However sometimes this property does not appear to have been set correctly and the VisibleIndex does not correspond to the column positions in the grid. I cannot reproduce this behaviour, it just happens occassionally.

    Is there anything I can do to force the grid to recalculate the VisibleIndex of its columns? I thought perhaps I could find the Column with the highest VisibleIndex and change its VisibleIndex value, which would not reorder columns but might force the grid’s column collection to recalculate the VisibleIndex for all columns.

    That said, how could the VisibleIndex ever be ‘wrong’ if I can see the columns in a certain order in the grid? Does the grid use a different property to sort its columns?

    kh

    Imported from legacy forums. Posted by kh (had 2102 views)

    User (Old forums)
    Member
    Post count: 23064

    You could try this:
    1. Find the minimum and maximum VisibleIndex of all the columns.
    2. Create a loop from minimum to maximum, and get the columns like this:
    Xceed.Grid.Column[] columns = new Xceed.Grid.Column[grid.Columns.Count];
    int counter = 0;
    for(int i=minimum; i<=maximum; i++)
    {
    column[counter] = grid.Columns.GetColumnAtVisibleIndex(i);
    counter++;
    }

    Imported from legacy forums. Posted by Tommy (had 3079 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.