如何将来自SQL查询的值存储到ComboBox组件中? [英] How to store values from an SQL query into a ComboBox component?
本文介绍了如何将来自SQL查询的值存储到ComboBox组件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对Borland C ++ Builder 6中的 TComboBox
组件有疑问。
I have a problem with the TComboBox
component in Borland C++Builder 6.
在ComboBox中,我想插入SQL查询的结果,例如:
In the ComboBox, I want to insert the result of an SQL query, eg:
ID value
---------
1 one
2 two
3 three
我要显示<向用户的code> value 列,例如一个
,两个
,三个
,但引用的值 ID
列。
I want to display the values of the value
column to the user, e.g. one
, two
, three
, but reference the values of the ID
column.
有人可以帮助我吗? Google没对我说很多。
Can anyone help me? Google did not say a lot about this to me.
推荐答案
有人在另一个论坛上回答了我,但我想分享这个解决方案和你
someone answered me on another forum but I would like to share this solution with you
我正在填写组合框
cbx1->Items->Clear();
cbx1->AddItem("one",(TObject*)1);
cbx1->AddItem("two",(TObject*)2);
cbx1->AddItem("three",(TObject*)3);
cbx1->ItemIndex = 0;
读取所选项目的ID
int ID;
ID = (int)(cbx1->Items->Objects[cbx1->ItemIndex]);
ShowMessage(ID);
这篇关于如何将来自SQL查询的值存储到ComboBox组件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文