程序代码:
FORM1=NEWOBJECT("Form_1") FORM1.SHOW &&显示表单 READ EVENTS && 开始事件处理 RETURN DEFINE CLASS FORM_1 AS FORM AUTOCENTER=.T. BORDERSTYLE=2 CAPTION="列表框(LISTBOX)示例一" *CLOSABLE=.F. DOCREATE=.T. HEIGHT=230 MAXBUTTON=.F. MINBUTTON=.F. MOVABLE=.F. SHOWTIPS=.T. SHOWWINDOW=2 WIDTH=275 WINDOWTYPE=1 ADD OBJECT LABEL1 AS LABEL WITH AUTOSIZE=.T.,CAPTION="可选字段",TOP=10,LEFT=18,HEIGHT=28,WIDTH=40,FONTSIZE=11 ADD OBJECT LABEL2 AS LABEL WITH AUTOSIZE=.T.,CAPTION="已选字段",TOP=10,LEFT=182,HEIGHT=28,WIDTH=40,FONTSIZE=11 ADD OBJECT LIST1 AS LISTBOX WITH TOP=30,LEFT=0,FONTSIZE=11 ADD OBJECT LIST2 AS LISTBOX WITH TOP=30,LEFT=175,FONTSIZE=11 ADD OBJECT COMMANDGROUP1 AS COMMANDGROUP WITH BUTTONCOUNT=4,LEFT=113,HEIGHT=THISFORM.LIST1.HEIGHT,TOP=30,WIDTH=51 PROCEDURE INIT CSTR="张援朝王抗美李援越刘抗日赵时代" WITH THISFORM.LIST1 FOR I=1 TO INT(LEN(CSTR)/6) .ADDLISTITEM(SUBSTRC(CSTR,(I-1)*3+1,3)) ENDFOR .MULTISELECT=.T. && 多重选择记录 ENDWITH THISFORM.LIST2.MULTISELECT=.T. && 多重选择记录 ENDPROC PROCEDURE COMMANDGROUP1.INIT WITH =0 WITH .COMMAND1 .AUTOSIZE=.T. .CAPTION=CHR(97) .FONTNAME="WINGDINGS 3" .FONTSIZE=11 .LEFT=5 .TOP=5 .TOOLTIPTEXT="右移记录" ENDWITH WITH .COMMAND2 .AUTOSIZE=.T. .CAPTION=CHR(99) .FONTNAME="WINGDINGS 3" .FONTSIZE=11 .LEFT=5 .TOP=49 .TOOLTIPTEXT="全部右移" ENDWITH WITH .COMMAND3 .AUTOSIZE=.T. .CAPTION=CHR(96) .ENABLED=.F. .FONTNAME="WINGDINGS 3" .FONTSIZE=11 .LEFT=5 .TOP=91 .TOOLTIPTEXT="左移记录" ENDWITH WITH .COMMAND4 .AUTOSIZE=.T. .CAPTION=CHR(98) .ENABLED=.F. .FONTNAME="WINGDINGS 3" .FONTSIZE=11 .LEFT=5 .TOP=134 .TOOLTIPTEXT="全部左移" ENDWITH ENDWITH ENDPROC PROCEDURE COMMANDGROUP1.CLICK WITH THISFORM DO CASE CASE .COMMANDGROUP1.VALUE=1 && 右移记录 FOR I=1 TO .LIST1.LISTCOUNT IF .LIST1.SELECTED(I) ZDM=.LIST1.LIST(I) .LIST2.ADDITEM(ZDM) .LIST1.REMOVEITEM(I) ENDIF ENDFOR CASE .COMMANDGROUP1.VALUE=2 && 记录全部右移 DO WHILE .LIST1.LISTCOUNT>0 .LIST2.ADDITEM(.LIST1.LIST(1)) .LIST1.REMOVEITEM(1) ENDDO CASE .COMMANDGROUP1.VALUE=3 && 左移记录 FOR I=1 TO .LIST2.LISTCOUNT IF .LIST2.SELECTED(I) ZDM=.LIST2.LIST(I) .LIST1.ADDITEM(ZDM) .LIST2.REMOVEITEM(I) ENDIF ENDFOR CASE .COMMANDGROUP1.VALUE=4 && 记录全部左移 DO WHILE .LIST2.LISTCOUNT>0 .LIST1.ADDITEM(.LIST2.LIST(1)) .LIST2.REMOVEITEM(1) ENDDO ENDCASE IF .LIST2.LISTCOUNT>0 .=.T. .=.T. ELSE .=.F. .=.F. ENDIF IF .LIST1.LISTCOUNT=0 .=.F. .=.F. ELSE .=.T. .=.T. ENDIF .REFRESH ENDWITH ENDPROC PROCEDURE DESTROY CLEAR EVENTS ENDPROC ENDDEFINE效果图
[ 本帖最后由 sdta 于 2012-9-4 17:52 编辑 ]