FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Seek/Search xBrowse Tree
Posts: 811
Joined: Tue May 06, 2008 04:28 AM

Seek/Search xBrowse Tree

Posted: Thu Feb 17, 2011 02:38 AM

Dear All,

How to Seek/Search an Item in xBrowse Tree?

Kind regards,

Frances

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 811
Joined: Tue May 06, 2008 04:28 AM

Re: Seek/Search xBrowse Tree

Posted: Thu Feb 17, 2011 09:08 AM

Dear All,

Not possible? any alternative way?

Kind Regards,

Frances

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Seek/Search xBrowse Tree

Posted: Thu Feb 17, 2011 12:48 PM
You need to make your own seek function and set that function to bSeek. In case of trees most likely all the items are not in a sorted order.

I suggest this approach:
Code (fw): Select all Collapse
oBrw:bSeek := { |c| SeekTree( oBrw, c ) }

//.....
//.....

function SeekTree( oBrw, cSeek )

   local oTree    := oBrw:oTree
   local oFound, oItem := oTree:oFirst
   local lFound   := .f.
   
   cSeek    := Upper( cSeek )

   do while oItem != nil
      if oItem:cPrompt = cSeek
         oFound   := oItem
         exit
      endif
      oItem    := oItem:GetNext()
   enddo
   if oFound != nil
      oBrw:oTreeItem := oFound
      lFound   := .t.
   endif

return lFound
Regards



G. N. Rao.

Hyderabad, India
Posts: 811
Joined: Tue May 06, 2008 04:28 AM

Re: Seek/Search xBrowse Tree

Posted: Fri Feb 18, 2011 06:10 AM
Dear Mr. RAO,

Thanks for the Input... I did this to make incremental search.. works for me.

Code (fw): Select all Collapse
oBrw:bSeek := { |c| uSeekTree( oBrw, Upper(c) ) }

...


STATIC FUNCTION uSeekTree( oBrw, cSeek )

 LOCAL oTree  := oBrw:oTree
 LOCAL oFound, oItem := oTree:oFirst
 LOCAL lFound := .F.

 oBrw:cSeek := cSeek

 DO WHILE oItem <> NIL

    IF oBrw:cSeek $ Upper(SubStr(oItem:cPrompt,1,Len(oBrw:cSeek)))
       oFound := oItem
       EXIT
    ENDIF

    oItem := oItem:GetNext()

 ENDDO

 IF oFound <> nil
    oBrw:oTreeItem := oFound
    oBrw:Refresh()
    lFound := .t.
 ENDIF

RETURN lFound



Kind Regards,

Frances
Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15

Continue the discussion