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", "")
GO TOP
of = CREATEOBJECT("_Form")
of.Show(1)
CLEAR ALL
RETURN
DEFINE CLASS _Form AS Form
Height=200
Width=350
ADD OBJECT Grid1 AS Grid WITH Top=10,Left=10,Height=140,Width=300,RowSourceType=1,RecordSource="表1"
ADD OBJECT Command1 AS CommandButton WITH Top=160,Left=10,Height=25,Caption="修改"
PROCEDURE Command1.Click
REPLACE 修改时间 WITH DTOS(DATE())+STRTRAN(TIME(), ":", "")
thisform._SetCell(1, 1, RECNO())
ENDPROC
FUNCTION _SetCell(nRow, nCol, nRecno)
IF nRow <= nRecno
GO nRecno
this.grid1.SetFocus
this.grid1.ActivateCell(nRow, nCol)
DO WHILE RECNO() != nRecno
this.grid1.DoScroll(IIF(RECNO() < nRecno, 1, 0))
this.grid1.SetFocus
this.grid1.ActivateCell(nRow, nCol)
ENDDO
ENDIF
ENDFUNC
ENDDEFINE
CREATE CURSOR 表1 (项目 C(20))
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
ADD OBJECT List1 AS ListBox WITH Top=10,Left=10,Height=80,Width=280,RowSourceType=3,;
RowSource = "SELECT 项目 FROM 表1 INTO CURSOR 列表"
ADD OBJECT Command1 AS CommandButton WITH Top=95,Left=10,Height=25,Caption="置顶"
PROCEDURE Command1.Click
FOR i = 1 TO thisform.List1.ListCount
IF thisform.List1.Selected(i)
thisform.List1.TopIndex = i
EXIT
ENDIF
ENDFOR
ENDPROC
ENDDEFINE