FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour how to detect multiselect of xBrowse
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
how to detect multiselect of xBrowse
Posted: Thu Jan 29, 2009 10:27 PM
HI all,

here an other question about the multiselect feature of xBrowse.

I want to give the possibility to create groups of selected items of a browse.
A user might multi-select some rows and click at a button to create a group from those selected items.

If there is only one row selected it makes no sense to create a group for it.
I could test the len of oBrw:aSelected and tell the user after the group button is pressed that he has to select more than one row for building a group.

But my intention is to disable the grouping button if there is no multiselect and enable if yes.
The button is build with: WHEN len( oBrw:aSelected ) > 1.
I just don't know where to call the oDlg:AEvalWhen().

The onChange event of the browse doesn't always change the button correctly.
Is there an other event to get the desired button change?

Thanks for every helping answers,
Detlef
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: how to detect multiselect of xBrowse
Posted: Fri Jan 30, 2009 01:03 AM
Hello Detlef

it is your test...
check it
compiled with xharbour

    #INCLUDE "FiveWin.ch"
    #INCLUDE "XBrowse.ch"

    function Main()

       local oDlg, aLin := {}, i, oBrw
			 local oBtn
			 
       for i := 1 TO 6
          AAdd( aLin, {  chr( 64 + i ), "Item " + str( i ) } )
       next

       DEFINE DIALOG oDlg FROM 0, 0 TO 14, 48
       
       @ 1,18 button oBtn prompt "Group" of oDlg ;
       action( msginfo( "::aSelected > 1" ) ) 
       oBtn:Disable()
       
       oBrw := TxBrowse():New( oDlg )
       
       oBrw:SetArray( aLin )
       oBrw:CreateFromCode()

       with object oBrw
          :nRowDividerStyle := LINESTYLE_BLACK
          :nColDividerStyle := LINESTYLE_BLACK
          :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS


          :aCols[1]:cHeader := 'Cod'
          :aCols[2]:cHeader := 'Description'

          :bClrStd          := { || { CLR_BLACK, CLR_WHITE  } }
          :bClrSel          := { || { CLR_BLUE,  CLR_YELLOW } }
          :bClrSelFocus     := { || { CLR_HRED,  CLR_CYAN   } }
          :bClrRowFocus     := { || { CLR_WHITE, CLR_RED    } }
          :lHScroll         := .f.
          :nStretchCol      := 2
          :bLClicked					:= {|| if( len( oBrw:aSelected ) > 1, ;
          															oBtn:Enable(),;
          														  oBtn:Disable()) }
       end
       ACTIVATE DIALOG oDlg 


    RETURN NIL
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
Re: how to detect multiselect of xBrowse
Posted: Fri Jan 30, 2009 07:47 AM

Daniel,

thanks a lot for your code.
It works exactly as i wanted.

Thanks and regards,
Detlef

Continue the discussion