This is a migrated thread and some comments may be shown as answers.

[Solved] Moving column to end of grid

1 Answer 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jerry Kurata
Top achievements
Rank 1
Jerry Kurata asked on 03 Sep 2010, 01:05 AM
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?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Sep 2010, 08:35 AM
Hello Jerry Kurata,

 
I have tested the scenario you want to achieve and everything works as expected on my side. I am sending you the sample project I used for reproducing the issue. In case it does not correspond to your exact requirements, please provide more details about your application so that we could suggest a more appropriate solution.

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Jerry Kurata
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or