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

表格(Grid)控件 | 2015-03-13 15:25:32 | 阅读 2971 次 | 评论(0)
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
文章评论,共0条
游客请输入验证码
浏览264833次
最新评论
  • cstdio:ooooooo
  • sdta:从VFP入手也不错
  • yuanhouwen:尊敬的sdta大神:作为一个编程外行,看到你关于操控EXCEL的编程程序我觉得特别神奇,想向你...