by Antonio Linares » Sat Nov 28, 2009 10:00 am
Frances,
Purpose of freezing some columns is that they always remain on the left during the entire runtime of the browse.
XBrowse allows the user to rearrange the columns by dragging column headers. If the user drags un-freezed columns into the freezed area or drags freezed columns outside the freezed area, the very intention of the programmer is defeated.
Till version 9.10, the only option available to the programmer to protect the freeze is by setting oBrw:lAllowColSwapping to false, thereby denying the user the facility to rearrange columns. But with this approach the user can not rearrange any columns, even within the unfreezed area or within the freezed area, which is not against the intentions of the programmer.
The change made in the MoveCol() method of version 9.11 is that the user can still rearrange the columns by dragging, but he can not drag an un-freezed column into the freezed area or a freezed column out of the freezed area. But he can rearrange columns within the un-freezed area or within the freezed area. This does not defeat the purpose of freezing and at the same time allows the user maximum possible flexibility to rearrange the columns without disturbing the freeze.
Though even while programming setting the freeze after rearranging the columns is a better idea, it is appreciated that this restriction in the MoveCol() method should be applicable to the user at runtime but not
necessarily to the programmer while writing the code. This is implemented in verson 9.12. With this change, the programmer can still use MoveCol() method to rearrange columns in his program without any restriction and at the same time the user can not disturb the freeze at runtime.
To implement this change in version 9.11, the following lines may be changed:
Line 4968: METHOD MoveCol( xFrom, xTo, lRefresh, lUser ) CLASS TXBrowse
Line 4973: DEFAULT lRefresh := .t., lUser := .f.
Line 4986: if lUser .and. ! Empty( ::nFreeze )
Line 9079: ::oBrw:MoveCol( Self, oCol, .t., .t. )
In addition to MoveCol() method, two other methods are available to the
programmer (not to the user) for rearranging the columns, without any
restrictions.
1. SwapCol( xcol1, xCol2, lRefresh )
This method swaps two columns without disturbing the position of other columns.
Difference between MoveCol and SwapCol is explained below:
As an example, in a browse having ten columns, after MoveCol( 7, 3 ), the resultant order of columns is :
1, 2, 7, 3, 4, 5, 6, 8, 9, 10
After SwapCol( 7, 3 )
1, 2, 7, 4, 5, 6, 3, 8, 9, 10
2. ReArrangeCols( aSequence, lRetainRest )
aSequence is an array of column creation numbers or column headers.
This method rearranges all columns in the revised sequence. If lRetainRest( true by default ) is true, columns not included in the aSequence are retained at the end in the original sequence else these remaining columns
are deleted.