xbrowse multiselect

Post Reply
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

xbrowse multiselect

Post by Silvio »

if I use on xbrowse :

oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROWMS

and select many records with mouse and ctrl

can I have on an array asel:={} the records I select ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

thanks
but How I can print only the record selected
can you make a small sample please
Best Regards, Saludos

Falconi Silvio
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post by ShumingWang »

oRpt:bSkip := { || oRpt:Cargo := ::rptSKIP( ) }

Method Rptskip() class Txbrowse
local n1,n1old


n1old:=::skip(1)
n1:=n1old

IF len(::aSelected)>0
While AScan( ::aSelected, If( ::nDatatype==DATATYPE_ARRAY,::nArrayAt,eval(::bKeyno)))==0
n1+=::skip(1)
if ::nDATATYPE<>DATATYPE_ARRAY
if eval(::bKeyno)==eval(::bkeyCount)
n1:=0
exit
end
else
if ::nArrayAt==len(::aArray)
n1:=0
exit
end
end
if n1==n1old
exit
end
n1old:=n1

enddo
end


If you want a more better method select()

#ifdef __HARBOUR__
METHOD Select( nOperation ) CLASS TXBrowse
#else
METHOD _Select( nOperation ) CLASS TXBrowse
#endif

local uBook, uCurRow, uOldRow, uTemp
local aTemp
local nAt, nLen
local lRefresh

if ::nMarqueeStyle != MARQSTYLE_HIGHLROWMS
return nil
endif

DEFAULT nOperation := 1

do case
case nOperation == 0 // delete all
if len( ::aSelected ) == 1 .and. Eval( ::bBookMark,, Self ) == ::aSelected[ 1 ]
lRefresh := .f.
else
lRefresh := .t.
endif
::aSelected := {}
if lRefresh .and. ::lCreated
::lRefreshOnlyData := .t.
::GetDC()
::Paint()
::ReleaseDC()
endif

case nOperation == 1
// .or. ( len( ::aSelected ) == 0 .and. nOperation != 4 )// Add current
// xtech
uBook := Eval( ::bBookMark,, Self )
nAt := Ascan( ::aSelected, uBook )
if nAt == 0
// Aadd( ::aSelected, uBook )
// xtech
If ::lCreated
::DrawLine( .t. )
Endif
endif

case nOperation == 2 // Swap key (Ctrl+LClick)
uBook := Eval( ::bBookMark,, Self )
nAt := Ascan( ::aSelected, uBook )
if nAt > 0
If ::lCreated
::DrawLine( .f. )
endif
::aSelected[ nAt ] := Atail( ::aSelected )
Asize( ::aSelected, len( ::aSelected ) - 1 )

else
Aadd( ::aSelected, Eval( ::bBookMark ))
If ::lCreated
::DrawLine( .t. )
endif
endif

case nOperation == 3 // Shift & lclick
uBook := Eval( ::bBookMark,, Self )
uCurRow := Eval( ::bKeyNo,,Self )
Eval( ::bBookMark, Atail( ::aSelected ), Self )
uOldRow := Eval( ::bKeyNo,,Self )
if uOldRow != uCurRow
::aSelected := { Atail( ::aSelected ) }
if uCurRow > uOldRow
CursorWait()
do while ( uTemp := Eval( ::bBookMark,, Self ) ) != uBook .and. !Eval( ::bEof, Self )
If Ascan( ::aSelected, uTemp ) == 0
Aadd( ::aSelected, uTemp )
Endif
Eval( ::bSkip, 1, Self )
enddo
CursorArrow()
else
CursorWait()
do while ( uTemp := Eval( ::bBookMark,, Self ) ) != uBook .and. !Eval( ::bBof, Self )
If Ascan( ::aSelected, uTemp ) == 0
Aadd( ::aSelected, uTemp )
endif
Eval( ::bSkip, -1, Self )
enddo
CursorArrow()
endif
Aadd( ::aSelected, uBook )
Eval( ::bBookMark, uBook, Self )
::lRefreshOnlyData := .t.
If ::lCreated
::GetDC()
::Paint()
::ReleaseDC()
endif
else
Eval( ::bBookMark, uBook, Self )
endif

case nOperation == 4 // Select all
uBook := Eval( ::bBookMark,, Self )
::aSelected := Array( ::KeyCount() )
nAt := 1
nLen := ::nLen
aTemp := ::aSelected
CursorWait()
Eval( ::bGotop, Self )
do while nAt <= nLen //.and. !Eval( ::bEof )
aTemp[ nAt++ ] := Eval( ::bBookMark,, Self )
Eval( ::bSkip, 1, Self )
enddo
Eval( ::bBookMark, uBook, Self )
CursorArrow()
::lRefreshOnlyData := .t.
If ::lCreated
::GetDC()
::Paint()
::ReleaseDC()
Endif

end case

return nil




return n1
Post Reply