I’m adding a new field to a list and view. To add the field to the view, I’m using this code:
view.ViewFields.Add('My New Field');
However this just tacks it on to the end of the view. How do I add the field to a particular column, or rearrange the field order? view.ViewFields is an SPViewFieldCollection object that inherits from SPBaseCollection and there are no Insert / Reverse / Sort / RemoveAt methods available.
I’ve found removing all items from the list and readding them in the order that I’d like works well (although a little drastic). Here is the code I’m using: