>CLEAR ALL > >SET REFRESH TO 2 &&Refresh the BROWSE every 2 seconds > > >CREATE Table AutoComp (Source c(20), Data C(254), Count I, Weight I, Created T, Updated T, User M) > >INDEX ON source +UPPER(LEFT(data,30))+padl(count,8) FOR !DELETED() tag data > >_screen.AutoCompTable="autocomp.dbf" > > >USE (HOME()+"samples\data\customer") && use table to get sample data > >SCAN NEXT 10 > > INSERT into autocomp values ("TXTNAME",Customer.contact,1,0,DATETIME()-1*86400*RECNO(),DATETIME()-2*86400*RECNO(),"") > > INSERT into autocomp values ("TXTCITY",Customer.city,1,0,DATETIME()-3*86400*RECNO(),DATETIME()-4*86400*RECNO(),"") > >ENDSCAN > > > >PUBLIC ox,oBrowse > >SELECT 2 > >USE autocomp order 1 > >BROWSE NOWAIT NAME oBrowse && show the autocomp table > > > >SELECT 1 > > > >CREATE CURSOR temp (name c(30),city c(30)) && temp table for grid > >APPEND blank && add 3 records > >APPEND blank > >APPEND blank > >GO TOP && go to the first record > >PUBLIC oTool as Toolbar >m.oTool = CREATEOBJECT('toolbar') >m.oTool.Show() >m.oTool.AddObject('txtName','Textbox') >m.oTool.txtName.visible = .T. >m.oTool.txtName.AutoCompTable = _SCREEN.AutoCompTable >m.oTool.txtName.AutoComplete = 1 > >PUBLIC oAutoComp as form > >oAutoComp=NEWOBJECT("form") > >WITH oAutoComp as Form > > .AllowOutput=.f. > > .Height=400 > > .AddObject("lblName" ,"label") > > WITH .lblName > > .Top=10 > > .Left=40 > > .Caption="Name" > > ENDWITH > > .addobject("txtname","textbox") > > WITH .txtName as TextBox > > .top=10 > > .left=90 > > .width=200 > > ENDWITH > > .AddObject("lblCity" ,"label") > > WITH .lblCity > > .Top=40 > > .Left=40 > > .Caption="City" > > ENDWITH > > .AddObject("txtcity","textbox") > > WITH .txtCity as textbox > > .top=40 > > .left=90 > > ENDWITH > > .AddObject("grid1","grid") > > WITH .grid1 as Grid > > .top=80 > > .left=30 > > .height=100 > > ENDWITH > > WITH .grid1.column1 > > .AddObject("txtName","textbox") > > .currentcontrol="txtName" > > .width=130 > > ENDWITH > > WITH .grid1.column2 > > .AddObject("txtCity","textbox") > > .currentcontrol="txtCity" > > .width=130 > > ENDWITH > > .AddObject("lst","mylistbox") > > WITH .lst > > .top=210 > > .left=20 > > ENDWITH > > .SetAll("visible",.t.) > > .Visible=.t. > >ENDWITH > > > >WITH oBrowse as Grid && position the browse > > .left=oAutoComp.Left+oAutoComp.Width > > .width=650 > > .Height=oAutoComp.Height*2 > > .FontSize=10 > > .AutoFit > >ENDWITH > > > >DEFINE CLASS MyListBox as ListBox > > PROCEDURE init > > WITH this as ListBox > > .AddItem("None") > > .AddItem("Alphabetical") > > .AddItem("Most Frequently") > > .AddItem("Most Recently") > > .AddItem("Custom") > > ENDWITH > > this.ListIndex=2 && initialize to Alphabetical > > this.click > > PROCEDURE click > > * change all controls that have Autocomplete property > > thisform.setall("autocomplete",this.ListIndex-1) > >ENDDEFINE