在文本文件VS 2010 C ++中保存listview项 [英] save listview item in a text file VS 2010 C++

查看:62
本文介绍了在文本文件VS 2010 C ++中保存listview项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,我可以将`Listview`中的项目保存到文本文件中?例如..



 col.1 | col.2 | COL3。| col.4 | col.5 
---------------------------------
数据|数据|数据|数据|数据
数据|数据|数据|数据|数据

解决方案

在文本文件中写入数据应该没问题,但您必须以一种格式写入数据才能读取数据出。如果是全部文本,您可以使用换行符\ n分隔商品数据。



当您编写存储代码时,您还应该编写阅读代码。并编写一些测试代码来验证您的解决方案;-)



旧学校解决方案将是 WritePrivateProfileString 。每个项目都是一个带编号的部分。


您也可以考虑对象序列化(只需谷歌搜索,您可以在网上找到教程和示例代码)。


< blockquote>一个选项是将listview导出到csv文件并从那里读回。 csv被广泛使用,您可以根据需要拆分数据项。



Google导出/导入listview到csv。



从这里开始 https://code.msdn.microsoft.com / windowsdesktop / export-ListView-to-CSV-39cd5f72 [ ^ ]


is there anyway that I can save the item in the `Listview` into a text file?? For example..

col.1| col.2| col3.| col.4| col.5
---------------------------------
Data | Data | Data | Data | Data 
Data | Data | Data | Data | Data

解决方案

Writing the data in a text file should be really no problem, but you must write the data in a format to read it out. If it is all text, you can separate the item data with a newline "\n".

When you write the storing code you should also write the reading code. And write some test code to verify your solution ;-)

An "old school" solution would be ini-files with WritePrivateProfileString. Each item would be a numbered section.


You may also consider object serialization (just Googling, you may find tutorials and sample code on the web).


One option is to export listview to csv file and read back from there. csv is widely used and you can split the data items as you wish.

Google "export/import listview to csv."

Start here https://code.msdn.microsoft.com/windowsdesktop/export-ListView-to-CSV-39cd5f72[^]


这篇关于在文本文件VS 2010 C ++中保存listview项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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