调用ADOConnection.GetFieldNames方法时,ListBox.Items可以用StringList替换吗? [英] Can a ListBox.Items be replaced by a StringList when calling ADOConnection.GetFieldNames method?

查看:232
本文介绍了调用ADOConnection.GetFieldNames方法时,ListBox.Items可以用StringList替换吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ADOConnection1.GetFieldNames('Employee', ListBox1.Items);


上面是调用此方法时应显示的代码.如果我尝试下面的代码,则总是在下一行代码中出现错误消息.

有什么方法可以用StringList替换ListBox.Items(可以在将StringList放入ListBox之前进行更改等)?


Above is the code that is shown that should be used when calling this method. If I try the code below, an error message comes up in the very next line of code, always.

Is there any way to replace the ListBox.Items with a StringList (which can be changed etc before placing this StringList into the ListBox)?

var
TablesList : TStringList;
//...
ADOConnection1.GetFieldNames('Employee', TablesList);
//code to modify the TablesList as I want to... then display the list in the listbox
ListBox1.Items := TablesList;



在将其显示给用户之前,我需要修改从GetFieldNames方法返回的列表...否则如何完成?



I need to modify the list returned from the GetFieldNames method before it may be displayed to the user... How else can this be done?

推荐答案

// fields before you call
procedure TForm1.buttonGetFieldsClick(Sender: TObject);
begin
  memoTableFields.Clear;
  ADOConnection1.GetFieldNames(editTable.Text, memoTableFields.Lines);
end;

// after editing you can set memo list
procedure TForm1.buttonSetFieldsClick(Sender: TObject);
begin
  listboxFields.Clear;
  listboxFields.Items := memoTableFields.Lines;
end;


这篇关于调用ADOConnection.GetFieldNames方法时,ListBox.Items可以用StringList替换吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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