how to detect multiselect of xBrowse

how to detect multiselect of xBrowse

Postby Detlef Hoefner » 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
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: how to detect multiselect of xBrowse

Postby Daniel Garcia-Gil » Fri Jan 30, 2009 1:03 am

Hello Detlef

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

Code: Select all  Expand view
    #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
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: how to detect multiselect of xBrowse

Postby Detlef Hoefner » Fri Jan 30, 2009 7:47 am

Daniel,

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

Thanks and regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 54 guests