VFP,当移动鼠标到表格某一个单元格时如何获取表格当前值

作者在 2015-03-13 15:25:32 发布以下内容
PUBLIC oForm
oForm = NEWOBJECT("Form1")
oForm.Show
RETURN

DEFINE CLASS Form1 As Form
    Height     = 300
    Width      = 420

    Add Object Grid1 As Grid
        
    PROCEDURE Load
        CREATE CURSOR TEMP (F1 C(10), F2 C(10), F3 I)
        INSERT INTO TEMP VALUES ("ABC", "123456", 101)
        INSERT INTO TEMP VALUES ("DEF", "654321", 202)
        INSERT INTO TEMP VALUES ("GHI", "456123", 303)
        INSERT INTO TEMP VALUES ("JKL", "789456", 404)
        INSERT INTO TEMP VALUES ("NMO", "123789", 505)
        GO TOP 
    ENDPROC
    
    PROCEDURE MyMouseMove
        LPARAMETERS nButton, nShift, nXCoord, nYCoord

        LOCAL nWhere, nRelRow, nRelCol
        nWhere  = 0
        nRelRow = 0
        nRelCol = 0

        IF thisform.Grid1.GridHitTest(nXCoord, nYCoord, @nWhere, @nRelRow, @nRelCol)
            IF nWhere == 3    && 单元格
                thisform.Grid1.ActivateCell(nRelRow, nRelCol)
                thisform.Grid1.Refresh
                thisform.Grid1.SetFocus
                thisform.Caption = TRANSFORM(thisform.Grid1.Columns[nRelCol].Text1.Value)
            ENDIF
        ENDIF
    ENDPROC

    PROCEDURE Grid1.Init
        FOR EACH oColumn IN this.Columns
            BINDEVENT(oColumn, "MouseMove", thisform, "MyMouseMove")
        ENDFOR
    ENDPROC
ENDDEFINE
表格(Grid)控件 | 阅读 4020 次
文章评论,共0条
游客请输入验证码
浏览402037次