To Antonio: Multiselect xBrowse

To Antonio: Multiselect xBrowse

Postby HunterEC » Tue Oct 23, 2012 3:16 pm

Antonio:
I'm addressing this to you because I need an answer ASAP (sorry, I know you're way too busy).

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 ?
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 ?
3. Any way of just displaying the selected ones ?


Thank you very much.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: To Antonio: Multiselect xBrowse

Postby Rick Lipkin » Tue Oct 23, 2012 5:11 pm

Consider this code .. one of our friends in this forum suggested this to me ..
Code: Select all  Expand view

aCols := oLbx:aSelected

For i = 1 to Len(aCols)
    oLbx:BookMark(aCols[i])
    _DoSomeFunc()
Next
 


aCols[i] returns the row bookmark .. oLbx:BookMark(aCols[i]) takes you to that row where the data can be evaluated.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: To Antonio: Multiselect xBrowse

Postby ukoenig » Wed Oct 24, 2012 12:30 pm

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 sample

3. 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 numbers

At Runtime :
oBrw:aArrayData := oBrw:nArrayAt // multiselected records
oBrw:GoTop()
oBrw:Refresh( .t. )

Image

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 )
ENDIF

Now the converter uses only these selected fields.

Image

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 :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 83 guests