Visual FoxPro 6.0~9.0解决方案与范例大全第169页4.17.5为递增查找输入部分值
组合框的KEYPRESS代码:
#DEFINE DELKEY 127 &&Asc码的127是什么?
LPARAMETERS nKeyCode, nShiftAltCtrl &&两个变量
LOCAL cDisplayValue &&变量
IF nKeyCode = DELKEY &&什么意思?
cDisplayValue = ALLTRIM(THIS.DisplayValue) &&组合框的displayvalue属性值(是组合框的名称)
IF LEN(m.cDisplayValue)=1 && m.cDisplayValue什么意思?
cDisplayValue = ""
ELSE
cDisplayValue = LEFT(cDisplayValue,LEN(cDisplayValue)-1)
ENDIF
ELSE
cDisplayValue = ALLTRIM(THIS.DisplayValue)+CHR(nKeyCode)
ENDIF
THISFORM.LockScreen = .T.
DO CASE
CASE EMPTY(m.cDisplayValue)
THISFORM.grdCust.RecordSource = " " &&改变表格RecordSource属性
CASE THIS.Value = "(All)"
SELECT Country AS Location,* FROM CUSTOMER;
INTO CURSOR Custs
THISFORM.grdCust.RecordSource = "Custs"
OTHERWISE
SELECT country AS location,* FROM CUSTOMER ;
WHERE UPPER(ALLTRIM(Customer.Country)) = UPPER(m.cDisplayValue); &&从左边比较字符串?
INTO CURSOR Custs &&把country左边的字符串与输入字符串相同的country
都保存到Custs临时表中?
THISFORM.grdCust.RecordSource = "Custs"
ENDCASE
THISFORM.ResetCombos(THIS) &&什么意思?
THISFORM.LockScreen = .F.
我的目的的是学习这个例子,并改成能实现递增查找组合框的列表值的功能,这样能快速从组合框中选定一个数值,然后刷新表单,使其他文本框显示与组合框显示数值相关的记录。