I FORGET to insert the source code
//----------------------------------------------------------------------------//
METHOD SaveState() CLASS TXBrowse
local oCol
local cState
local nFor, nLen
nLen := Len( ::aCols )
cState := Ltrim( Str( ::nRowHeight ) ) + ";"
for nFor := 1 to nLen
oCol := ::aCols[ nFor ]
cState += Ltrim( Str( oCol:nCreationOrder ) ) + ":" +;
Ltrim( str( oCol:nWidth ) ) + ":" +;
oCol:cHeader + ":" +;
iif(oCol:lHide, "H", "S") + ":" +;
Ltrim( str( oCol:nHeaderType ) ) // salvo il tipo di header
if nFor < nLen
cState += ";"
endif
next
return cState
//----------------------------------------------------------------------------//
METHOD RestoreState( cState ) CLASS TXBrowse
local oCol
local aMoved, aNaturalOrder
local cCol
local nLen, nOrder, nWidth, nFor, nAt, nHeight
local lHide,cHeader,j
if Empty( cState )
return nil
endif
aMoved := {}
aNaturalOrder := {}
nLen := Len( ::aCols )
nHeight := Val(StrToken( cState, 1, ";" ) )
if Empty( ::nRowHeight )
return nil
endif
// Check integrity
for nFor := 1 to nLen
cCol := StrToken( cState, nFor + 1, ";" )
if Empty( cCol )
return nil
endif
aadd( aNaturalOrder, nFor )
next
::nRowHeight := nHeight
for nFor := 1 to nLen
cCol := StrToken( cState, nFor + 1, ";" )
nOrder := Val( StrToken( cCol, 1, ":" ) )
nWidth := Val( StrToken( cCol, 2, ":" ) )
cHeader := StrToken( cCol, 3, ":" )
lHide := ( AllTrim( StrToken( cCol, 4, ":" ) ) == "H" )
nHeaderType := StrToken( cCol, 5, ":" )
nAt := Ascan( ::aCols, {|v| v:nCreationOrder == nOrder } )
if nAt > 0
oCol := ::aCols[ nAt ]
oCol:lHide := lHide
oCol:nWidth := nWidth
oCol:cHeader := cHeader
oCol: nHeaderType :=nHeaderType // restore tipo di header
endif
if nOrder != nFor
if nOrder != aNaturalOrder[ nFor ] .and. ( nAt := Ascan( aNaturalOrder, nOrder ) ) != 0
::SwapCols( nFor, nAt, .f. )
aNaturalOrder[ nFor ]:= nOrder
aNaturalOrder[ nAt ]:= nFor
endif
endif
next
::GetDisplayCols()
::Super:Refresh()
return nil
//----------------------------------------------------------------------------//