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

Moves first 3 columns to end of columns collection

2 Answers 46 Views
GridView
This is a migrated thread and some comments may be shown as answers.
SUNIL
Top achievements
Rank 2
Iron
SUNIL asked on 21 Oct 2010, 04:28 AM
I would like to move the first 3 columns in columns collection to end of the collection.
If there were a total of 10 columns, then I want to move columns 1,2 and 3 so that they are columns 8,9,10.

Thanks
Sunil

2 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 21 Oct 2010, 08:06 AM
Hello Sunil,

In the current version, on DataBindingComplete event you can move the columns by using
Columns.Move(oldIndex, newIndex)
or
Columns.Move(columnToMove, targetColumn, newIndex)

And if i remember correctly in the older versions you could also set Columns[0].Index = index, or something very similar.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
Accepted
SUNIL
Top achievements
Rank 2
Iron
answered on 22 Oct 2010, 06:59 PM
I used the following code with success to move the first three columns of 'Changes', 'Save' and 'Cancel' to the end of existing columns collections. The end result is that the last 3 columns are now 'Changes', 'Save' and 'Cancel'  in the same physical order.

            if (this.Columns["Changes"].Index < 3)
           {
               this.Columns.Move(this.Columns["Changes"].Index, this.Columns.Count-1);
           }
           if (this.Columns["Save"].Index <3)
           {
               this.Columns.Move(this.Columns["Save"].Index, this.Columns.Count-1);
           }
           if (this.Columns["Cancel"].Index <3)
           {
               this.Columns.Move(this.Columns["Cancel"].Index, this.Columns.Count-1);
           }
Tags
GridView
Asked by
SUNIL
Top achievements
Rank 2
Iron
Answers by
Emanuel Varga
Top achievements
Rank 1
SUNIL
Top achievements
Rank 2
Iron
Share this question
or