604
社区成员
发帖
与我相关
我的任务
分享
#include <dbclient.hpp>
int __fastcall CreateMemTableWithListView(TListView *lv, TDataSource *ds)
{
TClientDataSet *cds = new TClientDataSet(Application);
cds->FieldDefs->Add("f1", ftString, 10, False);
cds->FieldDefs->Add("f2", ftString, 10, False);
cds->FieldDefs->Add("f3", ftString, 30, False);
cds->CreateDataSet();
for (int i = 0; i < lv->Items->Count; i++)
{
cds->Append();
cds->Fields->Fields[0]->AsString = lv->Items->Item[i]->Caption;
for (int j = 0; j < lv->Items->Item[i]->SubItems->Count; j++)
{
cds->Fields->Fields[j + 1]->AsString = lv->Items->Item[i]->SubItems->Strings[j];
}
}
ds->DataSet = cds;
return cds->RecordCount;
}