Hi,
Is there any way to change the field position by code in the field layout?.
The ActualPosition property is read only and changing the Column property has not effect... I guess that the ActualPosition property as priority over the Column property.
Anyone?
Thanks.
Hi, any update on this, is the index is zero based or one based?
Great. Save and load customization after drag/drop + moving fileds programatically works.
One thing I noticed though. The FieldPosition.Column - it is zero based index or 1? Looks like this is impacting the actual position. In your sample, you have 4 columns and you are moving the first column to last by setting the column index as 4, so it is not zero based?
In your sample, (1)move the Salary column as 2nd column (name, salary...) and now actual position of Salary column is 1 (2)now click on move field (3) the actual position of salary column still show it as 1 eventhough it is first column in grid.
If you save this and load. It show the columns in order however the actual position doesn't appear to be corrrect.
Is this expected?
Thanks,
Muthu
Hello Muthu,
I have attached a modified version of the sample I attached the last time. It has the FieldLayoutSettings.AllowFieldMoving property set to WithinLogicalRow so you can grad column headers and still keep them next to each other without having them stack vertically. You can change this property a different value and it will still work, but it's easier to demonstrate if the column headers won't stack.
When you run the sample, re-arrange the column headers and then click the button to move the name column. It will put it all the way over the the right. Then, click the Save Customizations button, stop the application and run it again and click the Load Customizations button. It will arrange the columns in the order in which they were last saved.
Please let me know if you have any questions.
Sincerely,
CharlieSenior Developer Support EngineerMCTS
My issue was programatically moving columns (via a custom field selector GUI) + allowing user to do drag&drop was not working together. In otherwords after moving some columns and drag-drop of some other columns, doing SaveCustomization does not regain correct position.
Please let me know you described this as fixed in 2010.03.
Hello Muthu.
As of 2009 volume 2, the Field.ActualPosition property is no longer read-only. You can set it. The FieldLayout.EnsureUniqueFieldPositions() method is present also. Here is what you would need to do to swap the position if a field at run time:
FieldCollection fields = xamDataGrid1.FieldLayouts[0].Fields;fields[0].ActualPosition = new FieldPosition(4, 0, 1, 1);this.xamDataGrid1.FieldLayouts[0].EnsureUniqueFieldPositions();
I have attached a sample written in C# using 2010 volume 3 which demonstrates this. Just run the sample, click the button, and it will change the position of the 'name' column from zero to 4. Please let me know if you have any questions.