当前位置: 代码迷 >> VFP >> VFP liST 添加移除有关问题
  详细解决方案

VFP liST 添加移除有关问题

热度:4595   发布时间:2013-02-26 00:00:00.0
VFP liST 添加移除问题
现在有一表,让list1 读取其中的2-3个字段,然后点击添加按钮,添加到list2 ,也让list2 来显示这3个字段。问:可以实现么?关键代码是??

------解决方案--------------------------------------------------------
SQL code
*--- 表单上增加两个 LISTBOX (NAME 分别为 LIST1 与 LIST2)控件、COMMANDGROUP1(设置两个命令按钮,NAME 分别为 COMMAND1、COMMAND2,CAPTION 分别为“右移”“左移”)命令按钮组一个。*--- FORM.INITCREATE CURSOR TABNAME (姓名 C(6),性别 C(2),年龄 N(2))CSTR="李赵张王宋刘"FOR I=1 TO 6    INSERT INTO TABNAME VALUES (SUBSTRC(CSTR,I,1)+REPLICATE(CHR(I+64),5),IIF(MOD(I,2)=0,"男","女"),I*10)ENDFORWITH THISFORM.LIST1   .COLUMNCOUNT=FCOUNT()   .COLUMNWIDTHS="60,30,30"   SCAN      .ADDLISTITEM(姓名,RECNO(),1)      .ADDLISTITEM(性别,RECNO(),2)      .ADDLISTITEM(TRANSFORM(年龄),RECNO(),3)   ENDSCANENDWITHWITH THISFORM.LIST2   .COLUMNCOUNT=THISFORM.LIST1.COLUMNCOUNT   .COLUMNWIDTHS="60,30,30"ENDWITHTHISFORM.COMMANDGROUP1.COMMAND2.ENABLED=.F.*--- COMMANDGROUP.CLICKWITH THISFORM   DO CASE      CASE .COMMANDGROUP1.VALUE=1 && 右移记录             FOR I=1 TO .LIST1.LISTCOUNT               IF .LIST1.SELECTED(I)                  ZDM1=.LIST1.LIST(I,1)                  ZDM2=.LIST1.LIST(I,2)                  ZDM3=.LIST1.LIST(I,3)                  NUM=THISFORM.LIST2.LISTCOUNT && 关键之处                     NUM=NUM+1                  .LIST2.ADDLISTITEM(ZDM1,NUM,1)                  .LIST2.ADDLISTITEM(ZDM2,NUM,2)                  .LIST2.ADDLISTITEM(ZDM3,NUM,3)                  .LIST1.REMOVEITEM(I)               ENDIF            ENDFOR      CASE .COMMANDGROUP1.VALUE=2 && 左移记录             FOR I=1 TO .LIST2.LISTCOUNT                IF .LIST2.SELECTED(I)                   ZDM1=.LIST2.LIST(I,1)                   ZDM2=.LIST2.LIST(I,2)                   ZDM3=.LIST2.LIST(I,3)                   NUM=THISFORM.LIST1.LISTCOUNT && 关键之处                      NUM=NUM+1                   .LIST1.ADDLISTITEM(ZDM1,NUM,1)                   .LIST1.ADDLISTITEM(ZDM2,NUM,2)                   .LIST1.ADDLISTITEM(ZDM3,NUM,3)                   .LIST2.REMOVEITEM(I)                ENDIF             ENDFOR   ENDCASE   IF .LIST2.LISTCOUNT>0      .COMMANDGROUP1.COMMAND2.ENABLED=.T.   ELSE      .COMMANDGROUP1.COMMAND2.ENABLED=.F.   ENDIF   IF .LIST1.LISTCOUNT=0      .COMMANDGROUP1.COMMAND1.ENABLED=.F.   ELSE      .COMMANDGROUP1.COMMAND1.ENABLED=.T.   ENDIF  .REFRESHENDWITH
  相关解决方案