Multiple selection on a XBROWSE

Multiple selection on a XBROWSE

Postby HunterEC » Sat Oct 05, 2013 5:25 am

Guys:

How I can let the user do multiple selection on a xbrowse ? For example, marking up invoices to pay. I thought on creating an array where I will store the RECNO() of each record marked; then define a column that displays / hides a checkmark based on this array's contents. Does XBROWSE have a method or function to do this ? Thank you.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Multiple selection on a XBROWSE

Postby Richard Chidiak » Sat Oct 05, 2013 5:58 am

oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROWMS // multisel does the job

you can mark the lines needed by clicking

then

FOR I = 1 TO LEN(oBRW:aSELECTED) // obrw:aSELECTED is an array containing recnos marked

dbgoto->(oBRW:aSELECTED[I]))
.....
next

Hth

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Multiple selection on a XBROWSE

Postby HunterEC » Sun Oct 06, 2013 3:40 am

Richard:

Thank you very much for your solution. Now, using the mouse, it's prone to the user not pressing Ctrl and losing all marked records. It's there a way like marking a checkbox in a column ? This way the user just clicks on the checkbox and forgets about pressing the Ctrl key for multiselect.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Multiple selection on a XBROWSE

Postby Richard Chidiak » Sun Oct 06, 2013 4:53 am

You have to program it

This is what i do in one of my programs,

Hth

Richard

Code: Select all  Expand view

BMPADDCOL(oBrw:aCols[01])
oBrw:aCols[01]:bBmpData   := { || PROTABLE(ATABLE) }  
oBRW:blDblClick := { | nRow, nCol, nKey |CHECKTAB(@ATABLE,OBRW) }

FUNCTION BMPADDCOL(OCOL)
oCol:AddBmpFile( DIRAPPLI() + "BMP\BLEU.BMP" ,1, .T. )
oCol:AddBmpFile( DIRAPPLI() + "BMP\VERT.BMP" ,2, .T. )
oCol:AddBmpFile( DIRAPPLI() + "BMP\JAUNE.BMP", 3, .T. )
oCol:AddBmpFile( DIRAPPLI() + "BMP\ROUGE.BMP",4 , .T. )
oCol:AddBmpFile( DIRAPPLI() + "BMP\CYAN.BMP" ,5, .T. )
oCol:AddBmpFile( DIRAPPLI() + "BMP\BLANC.BMP" ,6, .T. )
oCol:AddBmpFile( DIRAPPLI() + "BMP\CHECKON.BMP" ,7, .T. )
oCol:AddBmpFile( DIRAPPLI() + "BMP\FINGER.BMP" ,8, .T. )
oCol:AddBmpFile( DIRAPPLI() + "BMP\CHECKOFF.BMP" ,9, .T. )
oCol:AddBmpFile( DIRAPPLI() + "BMP\CROIX.BMP" ,10, .T. )
RETURN NIL


FUNCTION PROTABLE(ATABLE)
LOCAL I := 0
IF LEN(ATABLE) = 0
   RETURN 9   // checkoff
ENDIF

FOR I = 1 TO LEN(ATABLE)
    IF ATABLE[I] =  the id you need to store
  RETURN 7    // checkon
    ENDIF
NEXT
RETURN 9 // checkoff

STATIC FUNCTION CHECKTAB(ATABLE,OBRW)
LOCAL I    := 0, ;
      IDEL := .F.

FOR I = 1 TO LEN(ATABLE)
    IF ATABLE[I] =  the id you need to store
       ATABLE[I] := 0
       IDEL      := .T.
       I         := LEN(ATABLE) + 1
    ENDIF
NEXT

IF ! IDEL
   AADD(ATABLE,the id you need to store)
ENDIF
OBRW:REFRESHCURRENT()
RETURN NIL


 
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Multiple selection on a XBROWSE

Postby nageswaragunupudi » Sun Oct 06, 2013 9:33 am

Please try this sample
Code: Select all  Expand view
#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"
#include "hbcompat.ch"

//----------------------------------------------------------------------------//

REQUEST DBFCDX

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oBrw, oFont

    XbrNumFormat( 'A', .t. )

   USE CUSTOMER NEW ALIAS "CUST" SHARED VIA "DBFCDX"

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 700,400 PIXEL FONT oFont

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS "FIRST", "CITY", "AGE", "SALARY" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw:InsCol( 1 )
      :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
      :SetCheck()
      :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
   END


   WITH OBJECT oBrw
      :nMarqueeStyle    := MARQSTYLE_HIGHLROW
      :lMultiSelect     := .f.
      :bClrSelFocus     := { || { CLR_BLACK, CLR_HGRAY } }
      :nStretchCol      := 3
      :aCols[ 1 ]:bClrSelFocus := { ||{  CLR_BLACK, CLR_WHITE } }
      :bLClicked        := { |r,c,f,oBrw| If( oBrw:MouseColPos( c ) == 1 , ;
                           If( ( f := AScan( oBrw:aSelected, oBrw:BookMark ) ) == 0, ;
                           AAdd( oBrw:aSelected, oBrw:BookMark ), ;
                           ADel( oBrw:aSelected, f, .t. ) ), nil ), ;
                           oBrw:RefreshCurrent() }

      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   xbrowser oBrw:aSelected

return (0)

//----------------------------------------------------------------------------//

 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests