简单示例,参考修改一下应该能用。
程序代码:
** test.prg CREATE CURSOR tt (f1 C(10), f2 C(10), f3 I, f4 I) INSERT INTO tt VALUES ("ABC", "123456", 101, 111) INSERT INTO tt VALUES ("DEF", "654321", 202, 222) INSERT INTO tt VALUES ("GHI", "456123", 303, 333) INSERT INTO tt VALUES ("JKL", "789456", 404, 444) INSERT INTO tt VALUES ("NMO", "123789", 505, 555) GO TOP of = CREATEOBJECT("form1") of.show(1) RETURN DEFINE CLASS form1 AS Form AutoCenter = .T. TextValue = "" ADD OBJECT Grid1 AS Grid WITH width=this.Width PROCEDURE Grid1.Init FOR EACH oColumn IN this.Columns BINDEVENT(oColumn.Text1, "RightClick", thisform, "myRightClick") ENDFOR ENDPROC PROCEDURE myRightClick IF (AEVENTS(aObj, 0) > 0) IF (PROPER(aObj[1].BaseClass) == "Textbox") myPop(thisform, aObj[1]) ENDIF ENDIF ENDPROC ENDDEFINE FUNCTION myPop(oForm1, oText) DEFINE POPUP pop FROM MROW(),MCOL() DEFINE BAR 1 OF pop PROMPT '复制' DEFINE BAR 2 OF pop PROMPT '粘贴' ON SELECTION POPUP pop mySelpop(POPUP(), PROMPT(), oForm1, oText) ACTIVATE POPUP pop DEACTIVATE POPUP pop RELEASE POPUP pop ENDFUNC FUNCTION mySelpop(cPopup, cPrompt, oForm1, oText) DO CASE CASE cPrompt == "复制" oForm1.TextValue = oText.Value CASE cPrompt == "粘贴" IF !EMPTY(oForm1.TextValue) IF VARTYPE(oForm1.TextValue) == VARTYPE(oText.Value) oText.Value = oForm1.TextValue ELSE IF (VARTYPE(oText.Value) == "N") oText.Value = VAL(oForm1.TextValue) ELSE oText.Value = TRANSFORM(oForm1.TextValue) ENDIF ENDIF ENDIF OTHERWISE ENDCASE DEACTIVATE POPUP (cPopup) RELEASE POPUP (cPopup) ENDFUNC