I added the requested option to the CSV-converter :
xBrowse-MULTISELECT Save / Restore
On a multi select xBrowse:
1. If I close the dialog / window, it returns the RECNO() of the highlighted record.
How can I close without selecting ?oBrw:nArrayAt := {}2. If I store the selected records in a file (dbf / INI),
how can I reselect them next time the user go to the xBrowse selection
routine ?have a look at the sample3. Any way of just displaying the selected ones ?@ 0,0 xbrowse oBrw of oWnd ;
object odbf ;
Rows { 10, 5, 30, 50, 100 } //
Array of record numbersAt Runtime :
oBrw:aArrayData := oBrw:nArrayAt // multiselected records
oBrw:GoTop()
oBrw:Refresh( .t. )
The Multiselected records are shown on top, reopening the dialog
( xBrowse-array loaded / created from a TXT-file )
The 1. record shown on top, is the 1. multiselected record.
IF FILE( "cFile1.txt" )
oBrw1:nArrayAt := READ_MULTI( "cFile1.txt", oBrw1 )
ENDIFNow the converter uses only these selected fields.
- Code: Select all Expand view
aStruc := DBStruct()
oBrw1 := TXBrowse():New( oDlg1 )
oBrw1:SetArray( aStruc)
oBrw1:aCols[1]:cHeader := Padr("FieldName", 15)
oBrw1:aCols[ 1 ]:nWidth := 125
oBrw1:aCols[2]:cHeader := "Typ"
oBrw1:aCols[2]:nDataStrAlign := AL_CENTER
oBrw1:aCols[2]:nHeadStrAlign := AL_CENTER
oBrw1:aCols[3]:cHeader := "Len"
oBrw1:aCols[3]:nDataStrAlign := AL_RIGHT
oBrw1:aCols[3]:nHeadStrAlign := AL_RIGHT
oBrw1:aCols[4]:cHeader := "Dec"
oBrw1:aCols[4]:nDataStrAlign := AL_RIGHT
oBrw1:aCols[4]:nHeadStrAlign := AL_RIGHT
oBrw1:CreateFromResource(220)
SetBrwStyle1( oBrw1 )
IF FILE( "cFile1.txt" )
oBrw1:nArrayAt := READ_MULTI( "cFile1.txt", oBrw1 )
ENDIF
...
...
ACTIVATE DIALOG oDlg1 ;
ON INIT ( oDlg1:Move( 50, 30, oDlg1:nWidth, oDlg1:nHeight, .f. ) ) ;
VALID ( SAVE_MULTI( oBrw1 ), .t. )
DBCloseAll()
RETURN NIL
// -----------------------
FUNCTION READ_MULTI( cText, oBrw )
LOCAL n, nCount, nTop
LOCAL oText := TTxtFile():New( "Test.txt" )
oText:New( c_path + cText )
IF oText:Open()
nCount := oText:RecCount()
oBrw:aSelected := Array(nCount)
FOR n = 1 to nCount
// MsgAlert( oText:ReadLine(), "Line" )
// define Records in xBrowse-multiselect-array
oBrw:aSelected[n] := VAL(oText:ReadLine())
IF n = 1 // the 1. Record to be shown in xBrowse
nTop := VAL(oText:ReadLine())
ENDIF
// MsgAlert( aLines[n], "Array" )
oText:Skip()
NEXT
oText:Close()
ENDIF
RETURN nTop
//---------------------------
FUNCTION SAVE_MULTI( oBrw1 )
LOCAL cArray := "", aSelRec := oBrw1:aSelected
I := 1
FOR I := 1 TO LEN( aSelRec )
cArray+= ALLTRIM(STR(aSelRec[I])) + CRLF
NEXT
MEMOWRIT( "cFile1.txt", cArray )
RETURN NIL
// ------- MULTISELECT - STYLE ------------
FUNCTION SetBrwStyle1( oBrw )
WITH OBJECT oBrw
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
:nColDividerStyle := LINESTYLE_BLACK
:nRowDividerStyle := LINESTYLE_BLACK
:lColDividerComplete := .T.
:bClrSelFocus := { || { 0, 13565951 } } // Focus
:bClrSel := { || { 0, 13551359 } } // Lostfocus
:nRecSelColor := 15512898
:bClrStd = { || If( oBrw:KeyNo() % 2 == 0, ;
{ If( ( oBrw:cAlias )->( Deleted() ), 16711680, 0 ), ;
If( ( oBrw:cAlias )->( Deleted() ), 14803711, 16775404 ) }, ;
{ If( ( oBrw:cAlias )->( Deleted() ), 16711680, 0 ), ;
If( ( oBrw:cAlias )->( Deleted() ), 11119614, 16639686 ) } ) }
:nRowHeight := 20
:nHeaderHeight := 30
:lAllowRowSizing := .F.
:lVScroll := .T.
:lHScroll := .T.
:SetRDD()
END
// { If( ( oBrw:cAlias )->( Deleted() ), CLR_HRED, CLR_BLACK ), RGB( 198, 255, 198 ) }, ;
RETURN
Best Regards
Uwe