DBLookupComboBox控件怎么用----在线等除了设置DataSource,DataField这两个属性之外还要设置那个属性?

解决方案 »

  1.   

    设置一下Lookup开头的那几个属性的值
      

  2.   

    listSource,listField,在这个框的显示的数据
      

  3.   

    如果是要显示某一字段的值,则listSource,listField和keyField都应该设置。
      

  4.   

    1.一种方法设置Dataset的新的lookup字段
    双击dataset,建立newfield,设置类型为lookup,指定以下几项
    datafield:指定要参考的字段,主数据集和参考数据集都包含该字段
    dataset:参考数据集
    keyfield:指定参考数据集中的关键字段(注意这个字段最后保存到数据库)
    listfield:指定要显示的字段。
    2.设置dblookupcombobox
    datasource:指定主数据源
    datafield:指定要参考的字段,主数据集和参考数据集都包含该字段
    listsource:参考数据源
    keyfield:指定参考数据集中的关键字段(注意这个字段最后保存到数据库)
    listfield:指定要显示的字段。
    用第一种方式的时候其实就跟第二中方法一样,不过不多用一个datasource
      

  5.   

    //刚才打字打那么多,其实在Delphi自带的帮助中就有,建议你以后多看看帮助,其原文如下:
    一. A lookup field defined for a dataset. 
    To specify list box items using a lookup field, the dataset to which you link the control must already define a lookup field. . To specify the lookup field for the list box items,1 Set the DataSource property of the list box to the data source for the dataset containing the lookup field to use.
    2 Choose the lookup field to use from the drop-down list for the DataField property.When you activate a table associated with a lookup control, the control recognizes that its data field is a lookup field, and displays the appropriate values from the lookup.二.A secondary data source, data field, and key.
     If you have not defined a lookup field for a dataset, you can establish a similar relationship using a secondary data source, a field value to search on in the secondary data source, and a field value to return as a list item. To specify a secondary data source for list box items,3 Set the DataSource property of the list box to the data source for the control.
    4 Choose a field into which to insert looked-up values from the drop-down list for the DataField property. The field you choose cannot be a lookup field.
    5 Set the ListSource property of the list box to the data source for the dataset that contain the field whose values you want to look up.6 Choose a field to use as a lookup key from the drop-down list for the KeyField property. The drop-down list displays fields for the dataset associated with data source you specified in Step 3. The field you choose need not be part of an index, but if it is, lookup performance is even faster.
    7 Choose a field whose values to return from the drop-down list for the ListField property. The drop-down list displays fields for the dataset associated with the data source you specified in Step 3.When you activate a table associated with a lookup control, the control recognizes that its list items are derived from a secondary source, and displays the appropriate values from that source.