如何获得正确的项目在一个Delphi的DBLookupComboBox被选中 [英] How do I get the Proper Item in a Delphi DBLookupComboBox to be Selected

查看:687
本文介绍了如何获得正确的项目在一个Delphi的DBLookupComboBox被选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到数据库查询的 DBLookupComboBox 。那部分工作正常。当我运行程序时, DBLookupComboBox 将填充查询的结果。我想在程序第一次运行时或运行时看到 DBLookupComboBox 新项目操作已启动。 (见下图)

I have a DBLookupComboBox that is wired to a database query. That part is working fine. When I run the program the DBLookupComboBox is populated with the results of the query. I'd like to to see the DBLookupComboBox populated with the first item "Please Select" when the program first runs or when a new item action is initiated. (See below image)

此外,如果我加载之前保存的数据库记录,选择了索引2快速消除,我将如何获得 DBLookupComboBox 以显示所选的条目?

Also, if I'm loading a previously saved database record that had selected Index 2 "Quick Elimination" how would I get the DBLookupComboBox to display that selected entry?

是,请选择是索引0,查询。

推荐答案

我的猜测是基础表字段的值是NULL而不是零,告诉DBComboBox

My guess would be that the value of the underlying table field is NULL rather than zero, which tells the DBComboBox that no value has yet been selected and it displays accordingly.

如果表中的值为零,我认为在组合的编辑字段中的文本将被选择

If the value in the table were zero, I thinkg the text in the edit field of the combo would be selected to indicate that, but I may recall this incorrectly.

无论如何,只需检查Field1.IsNull(或IsEmpty),然后将其设置为零即可。这意味着你不能再区分未知值(NULL)和没有选择的值(零),除非你阻止零值使它回到表中...

Anyway, just check for Field1.IsNull (or IsEmpty) and then set it to zero. It does mean that you can no longer distinguish between an "unknown value" (NULL) and "no selected value" (zero), unless you prevent the zero value from making it back into the table...

这篇关于如何获得正确的项目在一个Delphi的DBLookupComboBox被选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆