This question is locked. New answers and comments are not allowed.
Hi,
I want to move one of my dynamically added column's to the rightmost position in my grid. After adding the columns to my grid I thought I could execute the following line to do this.
gridSAR.Columns[MyColumnName].DisplayIndex = gridSAR.Columns.Count - 1;
However, the line throws the exception "index out of range. Must be non-negative and less that the size of the collection. Parameter name: Index". Thinking that it might be named based indexing into the collection that was failing I modified the code to be:
int OldDisplayIndex = gridSAR.Columns[MyColumnName].DisplayIndex;
int MaxIndex = gridSAR.Columns.Count -1;
gridSAR.Columns[MyColumnName].DisplayIndex = MaxIndex ;
The variable OldDisplayIndex is set to 16 and MaxIndex is set to 21. Setting of the DisplayIndex still throws the exception!
I don't see how this possible. Any thoughts?
I want to move one of my dynamically added column's to the rightmost position in my grid. After adding the columns to my grid I thought I could execute the following line to do this.
gridSAR.Columns[MyColumnName].DisplayIndex = gridSAR.Columns.Count - 1;
However, the line throws the exception "index out of range. Must be non-negative and less that the size of the collection. Parameter name: Index". Thinking that it might be named based indexing into the collection that was failing I modified the code to be:
int OldDisplayIndex = gridSAR.Columns[MyColumnName].DisplayIndex;
int MaxIndex = gridSAR.Columns.Count -1;
gridSAR.Columns[MyColumnName].DisplayIndex = MaxIndex ;
The variable OldDisplayIndex is set to 16 and MaxIndex is set to 21. Setting of the DisplayIndex still throws the exception!
I don't see how this possible. Any thoughts?