DBLookupCombobox的Datasource和DataField已经设置好,而且ListSource、ListField、KeyField已经设置好,相关的值下拉也见到,为什么下拉选择其它值时不能选择,只能显示打开表对应的字段值?

解决方案 »

  1.   

    把你的字段该成静态的。。即在adotable上双击,然后add all field
      

  2.   

    看看这个例子
    object Form1: TForm1
    Left = 198
    Top = 123
    Width = 455
    Height = 365
    Caption = 'Form1'
    Color = clBtnFace
    Font.Charset = DEFA U LT _ C H A R S E T
    Font.Color = clWi n d o w Te x t
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    OldCreateOrder = False
    PixelsPerInch = 96
    TextHeight = 13
    object Label1: TLabel
    Left = 352
    Top = 88
    Width = 64
    Height = 16
    Caption = ' Order No :'
    Font.Charset = DEFA U LT _ C H A R S E T
    Font.Color = clWi n d o w Te x t
    Font.Height = -1 3
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
    e n d
    object DBGrid1: TDBGrid
    Left = 24
    Top = 80
    Width = 288
    Height = 153
    DataSource = DataSource1
    TabOrder = 0
    TitleFont.Charset = DEFA U LT _ C H A R S E T
    TitleFont.Color = clWi n d o w Te x t
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
    e n d
    object DBLookupListBox1: TDBLookupListBox
    Left = 352
    Top = 120
    Width = 73
    Height = 95
    KeyField = 'OrderNo'
    ListField = 'OrderNo'
    ListSource = DataSource2
    TabOrder = 1
    e n d
    object Button1: TButton
    Left = 264
    Top = 272
    Width = 75
    Height = 25
    Caption = '退出'
    TabOrder = 2
    OnClick = Button1Click
    e n d
    object Table1: TTa b l e
    Active = Tr u e
    DatabaseName = 'DBDEMOS'
    TableName = 'customer. d b '
    Left = 192
    Top = 32
    e n d
    object DataSource1: TDataSource
    DataSet = Ta b l e 1
    Left = 11 2
    Top = 32
    e n d
    object DataSource2: TDataSource
    DataSet = Ta b l e 2
    Left = 328
    Top = 32
    e n d
    object Table2: TTa b l e
    Active = Tr u e
    DatabaseName = 'DBDEMOS'
    IndexFieldNames = 'CustNo'
    MasterFields = 'CustNo'
    MasterSource = DataSource1
    TableName = 'orders.db'
    Left = 392
    Top = 32
    e n d
    e n d
      

  3.   

    个人认为其实DELPHI提供的这些DBCOMBOBOX,DBEDIT之类的东西并不好用
      

  4.   

    1.可能是DBLookupComboBox对应的字段ReadOnly为True;
    2.可能是DBLookupComboBox对应的数据集的Active为False;
    3.可能是DBLookupComboBox的ListColumn的KeyField所选的字段名不对.
      

  5.   

    问题解决了。
    原来与数据库字段的类型有关和连接数据的方式有关。
    我的数据库是SQL SERVER,定义一个辅助表的字段为bigint类型,如果用DBE连接,就正常。但是我用的是ADO连接,不知道什么原因,ADO不支持bigint的lookup字段类型,把数据库的字段改为int类型就可以。
    谢谢各位的帮助!