Hi friends
Can anybody share the Incremental Search routine using TsBrowse.
I have a get and as i keep entering values in the get, the same values
should be searched in the attached Tsbrowser.
Thanks
- Ramesh Babu P
#include "FiveWin.ch"
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function Main()
local oWnd, oBrw, hBmp := ReadBitmap( CurDir() + "\go.bmp" )
local oSay, cSearch := ""
USE ( CurDir() + "\Customer" ) VIA "DBFCDX"
if ! File( CurDir() + "\LAST.CDX" )
INDEX ON Customer->Last TO ( CurDir() + "\LAST" )
endif
Customer->( OrdSetFocus( "LAST" ) )
Customer->( DbGoTop() )
DEFINE WINDOW oWnd TITLE "IncSearch"
@ 1, 1 LISTBOX oBrw ;
FIELDS hBmp, Customer->Last, Customer->First ;
HEADERS "", "Last", "First" ;
SIZE 220, 167
oBrw:bKeyChar = { | nKey, nFlags | Search( nKey, @cSearch ), oBrw:Refresh(),;
oSay:Refresh() }
@ 14, 2 SAY "Searching:" SIZE 60, 30
@ 14, 12 SAY oSay PROMPT cSearch SIZE 80, 30
ACTIVATE WINDOW oWnd ;
ON CLICK MsgInfo( "Click!" )
return nil
//----------------------------------------------------------------------------//
function Search( nKey, cSearch )
if nKey = 8
cSearch = SubStr( cSearch, 1, Len( cSearch ) - 1 )
else
cSearch += Upper( Chr( nKey ) )
endif
Customer->( DbSeek( cSearch, .t. ) )
return nil
//----------------------------------------------------------------------------//
// Incremental search of the contact list using a GET.
// Here we process keys dynamically in the contact lookup Get.
// We have to compensate for the use of the numeric keypad.
cClient:= space(20)
// Create a local copy so we can use it in the codeblock below
// Not needed if you are not using an instance var.
oLbx2:= ::oLbx2
// Bug: The GET below doesn't accept commas for some reason.
@ 25,5 get oGet var cClient of oBar2 ;
pixel;
size 120,20 ;
on change ( nOldRec:=self:cargo:recno(),;
oGet:nLastKey:=if( getKeyToggle(VK_NUMLOCK), oGet:nLastKey - 48, oGet:nLastKey ),;
cText:=trim(self:cText)+if(self:nLastKey>=32,chr(self:nLastKey),""),;
if(self:cargo:seek(upper(cText)), (click(),lAccept:=.t.), (self:cargo:goto(nOldRec),lAccept:=.f. ) ),;
oLbx2:refresh(),lAccept )
oGet:cargo:= ::oContact2
function click()
sndPlaySound("click.wav",2)
return nil
#include "FiveWin.ch"
REQUEST DBFCDX
* Incremental Search with a get object Example
//-----------------------------------------------------------------------//
FUNCTION Main()
LOCAL oWnd, oBrw
LOCAL cSearch, oSearch
USE Customer VIA "DBFCDX"
INDEX ON Customer->Last TO LAST
OrdSetFocus( "LAST" )
DbGoTop()
cSearch := SPACE(LEN(Customer->Last))
DEFINE WINDOW oWnd TITLE "IncSearch" ;
FROM 1,100 TO 212,408 PIXEL NOMAXIMIZE
@ 4,3 GET oSearch VAR cSearch OF oWnd ;
PIXEL size 145,17 ;
PICTURE "@!"
@ 30,1 LISTBOX oBrw ;
FIELDS Customer->Last, Customer->First ;
HEADERS "Last","First" ;
SIZE 300, 155 PIXEL
* This is the main trick.
oSearch:bPostKey = { || Search(oSearch:oGet:buffer),;
oBrw:Refresh() }
ACTIVATE WINDOW oWnd ON INIT WndCenter(oWnd:hWnd)
RETURN nil
//-----------------------------------------------------------------------//
FUNCTION Search(cSearch )
DbSeek( cSearch, .t. )
RETURN nil
**********
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 82 guests