本文介绍了您如何并排保存ListView项和SubItems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何并行保存ListView项和SubItems?
ListView1包含购买的商品,Subitems包含价格.下面是示例:
How can you save a ListView items and SubItems side by side?
ListView1 contains the purchased items and the Subitems contains the price. Below is the example:
Purchases Price
Apple 5
Orange 2
当我尝试保存信息时,得到以下信息:
When I try to save the information, I get the following:
ListViewItem: {Apple 1 @ 5}
ListViewItem: {Orange 1 @ 2}
这是我使用的代码:
Here is the Code I used:
Dim W As IO.StreamWriter
Dim i As Integer
W = New IO.StreamWriter("C:\Daily Purchases" & ".txt")
For i = 0 To ListView1.Items.Count - 1
W.WriteLine(ListView1.Items.Item(i))
Next
W.Close()
推荐答案
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim W As IO.StreamWriter
Dim i As Integer
W = New IO.StreamWriter("F:\TEMP\Daily Purchases" & ".txt")
For i = 0 To ListView1.Items.Count - 1
W.WriteLine(ListView1.Items.Item(i).Text + ":" + ListView1.Items.Item(i).SubItems(1).Text)
Next
W.Close()
End Sub
你就会有
苹果:5
香蕉:3
在您的文件中.
and you will have
Apple:5
Banana:3
in your file.
这篇关于您如何并排保存ListView项和SubItems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!