求教关于COMBO控件的使用
COMBO控件controlsource属性设置为表A的某字段,rowsource属性设置为表B的某字段,使用时如果从下拉列表中选择后保存,表A的字段内容变为刚才选择内容,但是如果不从下拉列表中选择,而是随便输入一串字符后保存,表A的字段内容不能变为输入的一串字符,请问这个如何解决,我既要下拉选择,又要输入的随意性,请问怎么解决?
************************************************** *-- Form: form1 (d:\documents\visual foxpro 项目\frmcombo.scx) *-- ParentClass: form *-- BaseClass: form *-- Time Stamp: 02/25/23 11:45:01 AM * DEFINE CLASS form1 AS form Top = 0 Left = 0 Height = 455 Width = 683 DoCreate = .T. Caption = "Form1" Name = "Form1" ADD OBJECT combo1 AS combobox WITH ; ControlSource = "", ; Height = 24, ; Left = 20, ; Top = 20, ; Width = 100, ; Name = "Combo1" PROCEDURE combo1.KeyPress &&在combo控件上键入回车,则将combo键的值写入控制数据源 LPARAMETERS nKeyCode, nShiftAltCtrl IF nkeycode=13 SELECT table2 GO TOP LOCATE FOR ALLTRIM(field2)=ALLTRIM(this.Value) IF FOUND() &&是数据源里的数据则添加,否则什么都不做 SELECT table1 INSERT INTO table1 (field1) VALUES (this.value) brow ENDIF ENDIF ENDPROC PROCEDURE combo1.Init ON ERROR cancel CREATE CURSOR table1 (field1 c(10)) this.ControlSource="table1" CREATE cursor table2 (field2 c(10)) SELECT table2 INSERT INTO table2 (field2) VALUES ("aaa") INSERT INTO table2 (field2) VALUES ("bbb") INSERT INTO table2 (field2) VALUES ("ccc") this.RowSourceType = 2 this.RowSource="table2" ENDPROC PROCEDURE combo1.DblClick &&在combo控件上双击时调用keypress事件 this.KeyPress(13) ENDPROC ENDDEFINE * *-- EndDefine: form1 **************************************************