VFP TreeView控件使用详解_treeview控件使用详解
VFP TreeView控件使用详解由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“treeview控件使用详解”。
VFP TreeView控件使用详解(2)工作帮手网(www.daodoc.comextKey this.cNextKey=allt(str(val(this.cNextKey)+1)+“_”)PRTURN cKey ENDPROC PROCEDURE refreshcombo this.cboparent.clear for i=1 to this.oletree.nodes.count this.cboparent.addlistitem(this.oletree.nodes.item(i)).fullpath,i,1)endfor ENDPROC *!*检查确保该表具有存储或恢复一个轮廓所需要的字段 PROCEDURE verifytablestructure LOCAL lafields[1,11],lnpos,laneeded[3],lncnt #DEFINE FIELD1_LOC“KEY” #DEFINE FIELD2_LOC“PARENT” #DEFINE FIELD3_LOC“TEXT” laNeeded[1]=FIELD1_LOC laNeeded[2]=FIELD2_LOC laNeeded[3]=FIELD3_LOC =AFIELDS(laFields,laNeeded[lnCnt])FOR lnCnt=1 to alen(laNeeded)lnPos=ASCAN(laFields,laNeeded[lnCnt])IF lnPos=0.or.laFields[lnPos+1]!='C' #DEFINE TITLE_LOC “Invalid Table Structure” #DEFINE MSG_LOC“The table must contain 3 character fields:”;+chr(13)+chr(13)+FIELD1_LOC+;chr(13)+FIELD2_LOC+chr(13)+FIELD3_LOC =meagebox(msg_loc,48+0+0,title_loc)return.f.ENDIF ENDFOR return.t.ENDPROC
PROCEDURE opendbf LPARAMETERS lcDBFNAME,llExclusive thisform.openedsuccefully=.t.#DEFINE ERR_LOC “Error” IF!file(lcDBFNAME)#DEFINE ERR1_LOC “Cannot find the specified file.” =meagebox(err1_loc,48+0+0,err_loc)return.f.ENDIF lcAlias=substr(lcDBFName,rat(“”,lcDBFNAME)+1)lcAlias=substr(lcAlias,1,at(“.”,lcAlias)-1)IF llExclusive use(lcDBFName)in 0 exclusive ENDIF IF!use(lcAlias)use(lcDBFName)in 0 shared ENDIF select(lcAlias)return thisform.openedsuccefully ENDPROC
*!*基于选择的项来允许/废止相应的按钮 PROCEDURE checkbuttons o=thisform.oletree IF isnull(o.selecteditem)then thisform.cmdnewchild.enabled=.f.thisform.cmdndeletenode.enabled=.f.ELSE thisform.cmdnewchild.enabled=.T.thisform.cmdndeletenode.enabled=.T.ENDIF ENDPROC
PROCEDURE init *!*用init 来检查OCX是否安装和装入
IF type(“this.oletree”)#“o”.or.isnull(this.oletree)return.f.ENDIF ENDPROC
PROCEDURE oletree.afterlabeledit LPARAMETERS cancel,newstring IF!isnull(newstring)this.selecteditem.text=newstring thisform.refreshcombo thisform.cboparent.value=this.selecteditem.index EDNIF ENDPROC
PROCEDURE oletree.nodeclick LPARAMETERS node thisform.refreshcombo thisform.cboparent.value=node.index thisofrm.checkbuttons ENDPROC
PROCEDURE oletree.lostfocus on key label F1 ENDPROC
PROCEDURE oletree.gotfocus on key label F1 help id_screen.activeform.helpcontextID ENDPROC
PROCEDURE cboparent.gotfocus thisform.refreshcombo thisform.checkbuttons ENDPROC
PROCEDURE cboparent.interactivechange thisform.oletree.nodes(this.value).selected=.t.thisform.checkbuttons ENDPROC
PROCEDURE cmdnewnode.click #DEFINE TXT_LOC“单击编辑文本” o=thisform.oletree o.nodes.add(,1,thisform.newkey(),TXT_LOC,0)ENDPROC
PROCEDURE cmddeletenode.click o=thisform.oletree IF!isnull(o.selecteditem)o.nodes.remove(o.selceteditem.key)ENDIF thisform.checkbuttons ENDPROC
PROCEDURE cmdloaddbf.click local lcOldAlias,laFields lcOldAlias=alias()lcDBFName=getfile('dbf')IF empty(m.lcDBFName)return ENDIF IF thisform.opendbf(lcdbfname)IF!thisform.verifytablestructure()return ENDIF o=thisform.oletree.nodes o.clear SCAN IF allt(parent)='0_' o.add(,1,allt(key),allt(text),0)ELSE o.add(allt(parent),4,allt(key,allt(text),0)ENDIF thisform.cNextKey=allt(str(val(key)+1)+“_”)ENDSCAN use IF!empty(lcOldAlias)select(lcOldAlias)ENDIF ENDIF thisform.checkbuttons ENDPROC
PROCEDURE cmdsavedbf.click local loNodes,lcParent,lcDBFName,lcOldAlias,lcOldSafety #DEFINE WARNING_LOC “Continuing will destroy all data in the table;and create a new table with three fields.”+chr(13)+“Do you want to continue?” #DEFINE WARN_LOC “WARNING” lcOldAlias=alias()lcOldSafety=set(“safety”)lcDBFName=getfile('dbf')IF empty(lcDBFName)&& 用户选择放弃 return ENDIF IF file(lcDBFName)IF thisform.opendbf(lcDBFName,.t.).and.;thisform.verifytablestructure().and.;meagebox(warning_loc,48+256+4,warn_loc)=6 set safety off zap set safety &lcOldSafety ELSE return ENDIF ELSE create table(lcDBFName)(key c(4), parent c(4), text c(60))ENDIF loNodes=thisform.oletree.nodes FOR i=1 to loNodes.count IF isnull(loNodes.Item(i).parent)lcparent=“0_” &&根 ELSE lcParent=loNodes.item(i)parent.key ENDIF insert into(lcDBFName)values(loNodes.item(i).key, lcParent, loNodes.item(i).text)ENDFOR use IF!empty(lcOldAlias)select(lcOldAlias)ENDIF thisform.checkbuttons ENDPROC
PROCEDURE cmdclear.click thisform.oletree.nodes.clear thisform.checkbuttons ENDPROC
PROCEDURE cmdnewchild.click #DEFINE TXT_LOC “单击编辑文本” o= thisform.oletree IF!isnull(o.selecteditem)then o.Nodes.add(o.seleceteditem.key,4,thisform.newkey(),txt_loc,0)ENDIF ENDPROC
PROCEDURE cmdclose.click thisform.release ENDPROC ENDDDEFINE
本篇《VFP TreeView控件使用详解(2)》为网站编辑为您精心挑选的示例范文,仅供参考,请勿照抄。建议将本站加入收藏夹。