感谢8楼,加时间能排在所有记录的前面,但不能显示在当前窗口列表框的第一行。
shenkj001@
SET CENTURY ON SET DATE TO ANSI SET MARK TO "/" SET HOURS TO 24 CREATE CURSOR 表1 (项目 C(20), 修改时间 C(14)) INSERT INTO 表1 VALUES ("项目01", "") INSERT INTO 表1 VALUES ("项目02", "") INSERT INTO 表1 VALUES ("项目03", "") INSERT INTO 表1 VALUES ("项目04", "") INSERT INTO 表1 VALUES ("项目05", "") INSERT INTO 表1 VALUES ("项目06", "") INSERT INTO 表1 VALUES ("项目07", "") INSERT INTO 表1 VALUES ("项目08", "") INSERT INTO 表1 VALUES ("项目09", "") of = CREATEOBJECT("_Form") of.Show(1) CLEAR ALL RETURN DEFINE CLASS _Form AS Form Height=310 Width=300 ADD OBJECT List1 AS ListBox WITH Top=10,Left=10,Height=80,Width=280,RowSourceType=3,; RowSource = "SELECT 项目 FROM 表1 ORDER BY 修改时间 DESC INTO CURSOR 列表" ADD OBJECT Command1 AS CommandButton WITH Top=95,Left=10,Height=25,Caption="修改" ADD OBJECT Grid1 AS Grid WITH Top=130,Left=10,Height=140,Width=280,RowSourceType=1 ADD OBJECT Command2 AS CommandButton WITH Top=275,Left=10,Height=25,Caption="修改" PROCEDURE Init thisform.List1.Requery SELECT 项目 FROM 表1 ORDER BY 修改时间 DESC INTO CURSOR 列表2 thisform.Grid1.RecordSource="列表2" ENDPROC PROCEDURE Command1.Click SELECT 表1 LOCATE FOR ALLTRIM(项目) == ALLTRIM(thisform.List1.Value) IF FOUND() REPLACE 修改时间 WITH DTOS(DATE())+STRTRAN(TIME(), ":", "") thisform.List1.Requery thisform.List1.ListIndex = 1 thisform.Grid1.RecordSource="" SELECT 项目 FROM 表1 ORDER BY 修改时间 DESC INTO CURSOR 列表2 thisform.Grid1.RecordSource="列表2" ENDIF ENDPROC PROCEDURE Command2.Click SELECT 表1 LOCATE FOR ALLTRIM(项目) == ALLTRIM(ALLTRIM(列表2.项目)) IF FOUND() REPLACE 修改时间 WITH DTOS(DATE())+STRTRAN(TIME(), ":", "") thisform.List1.Requery thisform.List1.ListIndex = 1 thisform.Grid1.RecordSource="" SELECT 项目 FROM 表1 ORDER BY 修改时间 DESC INTO CURSOR 列表2 thisform.Grid1.RecordSource="列表2" ENDIF ENDPROC ENDDEFINE