Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

The list has column a,b,f

I want to add some columns to the list and to the view. but in a defined order. I want column country and organization to be BETWEEN columns b and F

Is it possible?

SPList accessList = newSiteCollection.RootWeb.Lists.TryGetList("Workspace Access Rights");
                    if (accessList != null)
                    {
                        SPFieldCollection collFields = accessList.Fields;
                        collFields.Add("Country", SPFieldType.Text,false);
                        collFields.Add("Organisation", SPFieldType.Text, false);
                        collFields.Add("samAccountName", SPFieldType.Text, false);
                        SPView view = accessList.Views["All Items"];
                        view.ViewFields.Add("Country");
                        view.ViewFields.Add("Organisation");
                    }
share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Just remove all the fields and re-add them again.

share|improve this answer
add comment

Only in SharePoint does a private implementation detail of a class, namely of the order in which the fields in this "collection" are stored, have observable effects.

If designed correctly, it would be an SPFieldList that was indexable, and thus explicit that the order mattered. I wish MS would get some decent developers to work on SharePoint.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.