我正在尝试像这样动态填充ListView:
'for testing, arrPassed has two values("Ford" and "Chevy")
Dim arrPassed = New String() {"Ford", "Chevy"}
Dim colcount As New ListViewItem
colcount.Text = "count"
Dim colcar As New ListViewItem
colcar.Text = "car"
Dim intCount As Int32 = 1
For Each car As String In arrPassed
colcount.SubItems.Add(intCount)
colcar.SubItems.Add(car)
intCount = intCount + 1
Next
carList.Items.Add(colcount)
carList.Items.Add(colcar)
我所看到的只有:
算车?
当我想看时:
count car
1 Ford
2 Chevy
有没有办法动态地执行此操作?
谢谢!
答案 0 :(得分:2)
为了使ListView显示列,您需要将View属性设置为Details视图,并将一些列定义添加到Columns属性。这两个都可以在窗体的设计视图中的属性窗格中完成,并选择了ListView控件。