各位大虾:一 个很简单的问题,但是我怎么也找不到答案,帮帮忙。

lanchong781126 2003-08-25 11:01:25
一个listview

内容是这个样子的 :
clo1 col2 col3 col4
0 1 2 3
4 5 6 7
8 9 0 1

怎么样将它们显示在文本文件中
谢了先。
...全文
22 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
jishiping 2003-08-25
  • 打赏
  • 举报
回复
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString str;
TListItem* Item;

int hFile = FileOpen("C:\\test.txt", fmOpenWrite);
for(int n=0; n<ListView1->Columns->Count; n++) {
str = ListView1->Column[n]->Caption;
if (n>0) FileWrite(hFile, " ", 1);
FileWrite(hFile, str.c_str(), str.Length());
}
FileWrite(hFile, "\r\n", 2);

for(int n=0; n<ListView1->Items->Count; n++) {
Item = ListView1->Items->Item[n];
FileWrite(hFile, Item->Caption.c_str(),
Item->Caption.Length());
for(int i=0; i<Item->SubItems->Count; ) {
str = Item->SubItems->Strings[i++];
FileWrite(hFile, " ", 1);
FileWrite(hFile, str.c_str(), str.
Length());
}
FileWrite(hFile, "\r\n", 2);
}
FileClose(hFile);
}

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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