专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VFP

VFP里的组合框为什么输入数据不能保存到表,该怎么解决

发布时间:2010-05-24 22:03:27 文章来源:www.iduyao.cn 采编人员:星星草
VFP里的组合框为什么输入数据不能保存到表
有一个组合框 combo1的int属性的代码如下
thisform.combo1.rowsourcetype=0
thisform.combo1.additem (" ")
thisform.combo1.additem ("魏")
thisform.combo1.additem ("李")


combo1的keypress代码如下
LPARAMETERS nKeyCode, nShiftAltCtrl
if nKeyCode=13
 if !empty(this.displayvalue)
  this.additem(this.displayvalue)
 endif
endif


Rowsource Type 6字段

手工输入到COMBO1的数据无法保存,选择的倒可以,请问怎么解决?

------解决方案--------------------
将以下代码粘到 vfp 的 程序(Prg)中运行看一下效果吧:
VB code
Public oform1

oform1=Newobject("form1")
oform1.Show
Return

Define Class form1 As Form

    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"

    Add Object combo1 As ComboBox With ;
        RowSourceType = 6, ;
        RowSource = "t1.name", ;
        Height = 24, ;
        Left = 252, ;
        Top = 36, ;
        Width = 100, ;
        Name = "Combo1"

    Add Object grid1 As Grid With ;
        DeleteMark = .F., ;
        Height = 200, ;
        Left = 24, ;
        ReadOnly = .T., ;
        Top = 36, ;
        Width = 216, ;
        Name = "Grid1"

    Procedure Load
        Create Cursor t1 (Name c(10))
        Insert Into t1 Values ('张三')
        Insert Into t1 Values ('李四')
        Locate
    Endproc

    Procedure combo1.KeyPress
        Lparameters nKeyCode, nShiftAltCtrl
        If nKeyCode=13
            If Messagebox('确认要将此内容【'+Alltrim(This.DisplayValue)+'】添加到表中吗?',4+32+256,'信息提示')=6
                Insert Into t1 Values (Alltrim(This.DisplayValue))
            Endif
        Endif
    Endproc

Enddefine
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: