问题描述
我正在从事编程项目,卖药。
I am working on programming project, selling medicine.
我做了整个项目,但我不知道如何将文本文件读入listView,word by单词。
I did whole project, but I don't know how to read text file into listView, word by word.
例如。文本文件是这样的// medicine1
medicine1 ID price1
for exemple. text file is like this // medicine1medicine1 ID price1
medicine2
medicine2 ID price2
medicine2medicine2 ID price2
我有三列。我想要一列一个数据(信息),就像在txt文件中一样。
I have three columns. I wan't for one column one data (info), just like in txt file.
抱歉英语不好。
推荐答案
感谢您的帖子。
我建议您使用XML文件而不是.txt文件。但是,如果你坚持从文本文件中逐字逐句阅读它们。您可以尝试以下方法:
I would recommend you use XML file instead of .txt file. However, if you insist on reading them word by word from text file. You can try the following:
string[] words = reader.ReadToEnd().Split(' ');
它会自动将它分割到每个空间。然后,您可以每隔三个单词使用该字符串数组插入数据。
It will automatically split it on every space. Then you can insert your data by using that string array every three words.
问候,
Regards,
这篇关于C#如何使用listView从.txt文件读取和写入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!