Page 1 of 1
Multiple selection on a XBROWSE
Posted: Sat Oct 05, 2013 5:25 am
by HunterEC
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.
Re: Multiple selection on a XBROWSE
Posted: Sat Oct 05, 2013 5:58 am
by Richard Chidiak
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))
.....
next
Hth
Richard
Re: Multiple selection on a XBROWSE
Posted: Sun Oct 06, 2013 3:40 am
by HunterEC
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.
Re: Multiple selection on a XBROWSE
Posted: Sun Oct 06, 2013 4:53 am
by Richard Chidiak
You have to program it
This is what i do in one of my programs,
Hth
Richard
Code: Select all
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
Re: Multiple selection on a XBROWSE
Posted: Sun Oct 06, 2013 9:33 am
by nageswaragunupudi
Please try this sample
Code: Select all
#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)
//----------------------------------------------------------------------------//