如果 DBLookUpComboBox 没有在其中选择任何内容,则按钮将被禁用。

Button is disabled if DBLookUpComboBox hasnt got anything selected in it.

使用 Delphi XE2。

正在编写一个软件包来处理客户数据库。我有一个显示所有客户信息的表单,其中一个字段是一个查找组合框,旁边有一个按钮。 (查找组合框下拉一个包含多个字符串的列表)

打开表单时(insert/edit 模式)我需要禁用 lookupcombobox 旁边的按钮

我希望这会很简单。我自己似乎无法解决这个问题。

在 Delphi 的帮助中:

Vcl.DBCtrls.TDBLookupControl.KeyValue

Represents the common value of the KeyField field and the DataField field.

Use KeyField to determine the value represented by the lookup control (not the value displayed by the lookup control). When KeyValue is set, the lookup control attempts to find a record from the ListSource's dataset where the value of KeyField matches KeyValue. If such a match is found, the lookup control displays the value of ListField on that record.

所以当我使用它时,我可以执行以下操作:

  Button1.Enabled := not (DBLookupComboBox1.KeyValue = null);

这是没有连接到它的数据库,所以不知道如果之前组合框中有数据并且之前选择了其中一个项目会发生什么。你将不得不测试。