Page 1 of 1

xbrowse SelectRow method

PostPosted: Sat Mar 30, 2024 3:46 pm
by Silvio.Falconi
If I made to select all record on xbrowse

oBrw:SelectRow( 4 )

and the I wish deselect only one record

If I made oBrw:SelectRow( 0 ) it deselect all

how resolve ?

Re: xbrowse SelectRow method

PostPosted: Sun Mar 31, 2024 5:19 am
by nageswaragunupudi
oBrw:SelectRow( 2 ) toggles selection of the current row in focus.

Re: xbrowse SelectRow method

PostPosted: Sun Mar 31, 2024 5:22 am
by nageswaragunupudi
Or, if we want to deselect a specific row number, which is not the current row, we can do like this.
Code: Select all  Expand view
if ( nAt := AScan( oBrw:aSelected, nRecNo ) ) > 0
HB_ADel( oBrw:aSelected, nAt, .t. )
endif
oBrw:Refresh()

We do not recommend this, but this is possible.

Re: xbrowse SelectRow method

PostPosted: Mon Apr 01, 2024 10:55 pm
by Silvio.Falconi
nageswaragunupudi wrote:Or, if we want to deselect a specific row number, which is not the current row, we can do like this.
Code: Select all  Expand view
if ( nAt := AScan( oBrw:aSelected, nRecNo ) ) > 0
HB_ADel( oBrw:aSelected, nAt, .t. )
endif
oBrw:Refresh()

We do not recommend this, but this is possible.


Nages,

using this function

Code: Select all  Expand view
Function DeSelect_One(oBrw,oDbf)
   local  nRecNo:=oDbf:recno(),nAt
   if ( nAt := AScan( oBrw:aSelected, nRecNo ) ) > 0
        HB_ADel( oBrw:aSelected, nAt, .t. )
    endif
    oBrw:Refresh()
 return nil


It seem run ok

if I select two or three records and deselect one, the menu in the buttonbar remains unchanged because I added an if control

IiF(LEN(oBrw:aSelected)==0,Btnbar(1,.....)

thanks