none
为什么Listview不显示内容? 代码和图像如下: RRS feed

  • 问题

  • Public Class Form1
        Dim listview1Items(9) As ListViewItem
        Public Sub CreatListview1Items()
            Dim stocklist(9) As String
            For i = 0 To 9
                stocklist(i) = (i + 1).ToString
                listview1Items(i) = New ListViewItem(stocklist(i))
            Next i
        End Sub

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            CreatListview1Items()
            ListView1.Items.AddRange(listview1Items)
            For Each item In listview1Items
                Debug.Print(item.Text)
            Next
        End Sub

        Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
            On Error Resume Next
            MsgBox(ListView1.SelectedItems(0).Text)
        End Sub
    End Class

    内容肯定是已经加进去了,因为按下箭头键时,msgbox代码会被执行,

    2012年5月16日 16:32

答案

全部回复