如何得到DBListBox中选择项的内容?

nuinui 2000-06-20 06:26:00
如何得到DBListBox中选择项的内容?
在VB中用:
Text1.text=ListBox1.Text
可Delphi中却没有Text。
...全文
237 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hank 2000-06-22
  • 打赏
  • 举报
回复
Edit1.Text:=DBListBox1.Items.Strings[0];
想取那一个就是那一个!例如:
Edit1.Text:=DBListBox1.Items.Strings[SpinEdit1.Value];
Hibin 2000-06-22
  • 打赏
  • 举报
回复
Limu所述是Delphi推荐的标准用法,nuinui可认真看一下。
meijg 2000-06-20
  • 打赏
  • 举报
回复
先确定ItemIndex不为-1,取得ItemIndex
然后 DBListBox1.Items[ItemIndex]即为其内容
ling 2000-06-20
  • 打赏
  • 举报
回复
Text1.Text := DBListBox1.Items[DBListBox1.ItemIndex](前提:DBListBox1中有选中值, 否则ItemIndex=-1)

or

Text1.Text := DBListBox1.Field.AsString(假如对应的字段为字符型)
joyuce 2000-06-20
  • 打赏
  • 举报
回复
DBListBox1.Items[DBListBox1.ItemIndex]
joyuce 2000-06-20
  • 打赏
  • 举报
回复
可以用Items属性:
eg: Lable1.Caption:=DBListBox1.Items[0];
Limu 2000-06-20
  • 打赏
  • 举报
回复
Because you can select multiple items in a DBListBox,so you must use the Items property to access the values of a DBListBox.
Like this: DBListBox.Items(DBListBox.ItemIndex) is current selected item.
another like this:
for i:=0 to DBListBox.Items.Count-1 do
if DBListBox.Selected[i] then //if you selected i items,the condition value is True.
......

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧