IColumnFormatting.ColumnPosition Property

Gets or sets the zero based index of the column in the sheet. In case of WBS fields, this is Expanded WBS sheet.
Property ColumnPosition() As Integer
This language is not supported or no code example is available.
int ColumnPosition {get; set;}
This language is not supported or no code example is available.

Property Value

int

The column index. If set to -1, than the column position was not set yet.

Remarks
 
If the value of this property is -1, the column position was not set yet and the column will be placed automatically, e.g. to the end. Note, the columns of WBS fields start at index 26 in the expanded WBS worksheet, and all sheet columns 0-25 are hidden.

Setting the position of WBS fields

The easiest way to set a WBS field position safely is to call IWbsFieldsRepository.SetFieldPosition method. It takes care of the problems described below.

If you set the ColumnPosition property for a WBS field, this doesn't mean that the positions of other fields are automatically adjusted. The procedure is more complicated and there may be two cases.

1. You create a new field, set the position in its IWbsField.Formatting property and then you add it to the repository with IWbsFieldsRepository.AddField method. The positions of other WBS fields are not adjusted at this moment yet. But when you call IWbsFieldsRepository.RepaintWbsWithChanges afterwards, the column will be correctly inserted BEFORE an existing column at the specified position and thus the new column will be at this position. The positions of the other fields to the right will be increased as well. Remember, if you use IEstimate.CheckAndRepaint instead of IWbsFieldsRepository.RepaintWbsWithChanges, the final order may be nondeterministic, see the case 2 below.

You can add multiple new fields this way and call IWbsFieldsRepository.RepaintWbsWithChanges just once. The new columns will be inserted in the same order as their IWbsFieldsRepository.AddField was called. For example, you create three fields A, B and C, and set the position of all of them to the same value 30. Then you call IWbsFieldsRepository.AddField for A, then for B and then for C. After a call to IWbsFieldsRepository.RepaintWbsWithChanges, the positions of the fields will be: A=32, B=31 and C=30. It's because A was inserted at the position 30 as the first one. Then B was inserted at 30 and the position of A has increased to 31. And finally, C was inserted at 30 and the positions of B and A have increased.

2. You update the position of one or more existing WBS fields in their IWbsField.Formatting property and then you apply the change with IWbsFieldsRepository.UpdateField. In such a case, you cannot use IWbsFieldsRepository.RepaintWbsWithChanges to repaint the changes. You need to use more powerful but also much slower IEstimate.CheckAndRepaint method. But this method has no track of the order in which the changes to the field positions were made. It handles and removes any gaps between columns correctly. For example, it corrects the positions 30, 31, 35, 36 to 30, 31, 32, 33. Furthermore, it places the columns that were not explicitly positioned yet (their position is -1) at the end. But it cannot place the columns deterministically, if there are multiple columns with the same position. For example, there are three fields with position set to 30. Their relative order will be selected randomly by IEstimate.CheckAndRepaint in such a case. Similarly, multiple columns with the position set to -1 will be placed at the and randomly. But from this moment on, these positions will be persisted and will not change anymore.

If you want to avoid any uncertainty in the order of the columns with the same ColumnPosition, you need to adjust positions of all affected fields manually before you call IEstimate.CheckAndRepaint. For example, you have three existing fields: A at 26, B at 27 and C at 28. You want moving C to 27 so you set its ColumnPosition to 27 and you confirm the change with IWbsFieldsRepository.UpdateField. Now both, B and C have position 27 and you cannot be sure in which order they will be displayed after IEstimate.CheckAndRepaint. You must also set the position of B to 28 and apply it with IWbsFieldsRepository.UpdateField. Now the order is completely deterministic and you can call IEstimate.CheckAndRepaint.

Setting the position of Minutes fields

To set a minutes field position, call IMinutesFieldManager.MakeFieldsVisible method.

Version
 
Available since QDV 7.18.655.

.NET Framework

Supported in: 4.8, 4.7, 4.6, 4.5.2

In this article

Definition